Skip to content
Snippets Groups Projects
Unverified Commit d4a791b9 authored by Konstantin Tsabolov's avatar Konstantin Tsabolov Committed by GitHub
Browse files

Merge pull request #2 from spherity/chore/update-dependencies

Reorganize attestation-manager
parents ccb2cd58 6098aafc
No related branches found
No related tags found
No related merge requests found
Showing
with 229 additions and 130 deletions
......@@ -19,6 +19,7 @@ node_modules/
apps/*/node_modules
/dist
/apps/**/dist/
*.tsbuildinfo
# Logs
/logs
......
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
ecmaVersion: 2021,
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'airbnb-base',
'airbnb-typescript/base'
],
root: true,
env: {
node: true,
jest: true,
},
plugins: ['prettier', '@typescript-eslint/eslint-plugin', 'jest'],
extends: [
'prettier',
'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
],
ignorePatterns: ['.eslintrc.js'],
overrides: [],
settings: {
jest: {
version: '29',
},
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
"@typescript-eslint/ban-ts-comment": "off",
"prefer-spread": "off"
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': [1, { argsIgnorePattern: '^_' }],
},
overrides: [
{
files: [
'*.spec.ts',
'*.e2e-spec.ts',
'__mocks__/*.ts',
'__mocks__/**/*.ts',
],
rules: {
'@typescript-eslint/no-explicit-any': 0,
'jest/no-mocks-import': 0,
},
},
],
};
# Ignore everything
*
# Except for these files
!*.ts
!*.d.ts
!jest.config.js
# .. also in subdirectories
!*/
# ... in these ones
!src/*
# Explicitly ignore these locations
node_modules
dist
{
"singleQuote": true,
"trailingComma": "all"
}
\ No newline at end of file
}
{
"jsc": {
"preserveAllComments": true,
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"target": "es2022"
},
"module": {
"type": "es6"
},
"sourceMaps": true,
"exclude": [".spec.ts", ".e2e-spec.ts"]
}
/** @type {import('jest').Config} */
import { readFileSync } from 'node:fs';
const swcConfig = JSON.parse(readFileSync('./.swcrc', 'utf8'));
export default {
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
transform: {
'^.+\\.ts$': [
'@swc/jest',
{
...swcConfig,
sourceMaps: false,
exclude: [],
swcrc: false,
},
],
},
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
// ESM modules require `.js` extension to be specified, but Jest doesn't work with them
// Removing `.js` extension from module imports
'^uuid$': 'uuid',
'^(.*)/(.*)\\.js$': '$1/$2',
},
collectCoverageFrom: ['src/**/*.(t|j)s'],
coverageReporters:
process.env.CI === 'true'
? ['text-summary', 'json-summary']
: ['text-summary', 'html'],
coveragePathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/test/',
'<rootDir>/coverage/',
'<rootDir>/dist/',
'<rootDir>/**/test',
'@types',
'.dto.(t|j)s',
'.enum.ts',
'.interface.ts',
'.type.ts',
'.spec.ts',
],
coverageDirectory: './coverage',
// With v8 coverage provider it's much faster, but
// with this enabled it's not possible to ignore whole files' coverage
coverageProvider: 'v8',
};
{
"collection": "@nestjs/schematics",
"sourceRoot": "src"
"sourceRoot": "src",
"compilerOptions": {
"builder": "swc",
"typeCheck": true
}
}
......@@ -5,120 +5,82 @@
"author": "Shirdhar",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"clean": "rm -r dist",
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"dbSchema": "npx prisma db push --schema=./src/prisma/schema.prisma",
"prisma:generate": "prisma generate --schema=./src/prisma/schema.prisma",
"prisma:migrate": "npx prisma migrate deploy --schema=./src/prisma/schema.prisma",
"prismaStudio": "npx prisma studio",
"start": "nest start",
"start:docker": "pnpm prisma:generate && pnpm dbSchema && pnpm start",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"start:docker": "yarn prisma:generate && yarn dbSchema && yarn start",
"lint": "eslint --fix",
"lint:all": "npm run lint -- .",
"format": "prettier --write",
"format:all": "npm run format -- .",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "jest --config ./test/jest.config.js"
},
"dependencies": {
"@elastic/ecs-winston-format": "^1.3.1",
"@nestjs/axios": "0.0.5",
"@nestjs/common": "^8.0.0",
"@nestjs/config": "^1.1.6",
"@nestjs/core": "^8.0.0",
"@nestjs/mapped-types": "*",
"@nestjs/microservices": "^8.2.6",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/swagger": "^5.2.0",
"@nestjs/terminus": "^8.0.4",
"@prisma/client": "^3.9.2",
"@types/express": "^4.17.13",
"@types/jest": "27.0.2",
"@types/jsonwebtoken": "^8.5.9",
"@types/node": "^16.0.0",
"@elastic/ecs-winston-format": "^1.5.0",
"@nestjs/axios": "^3.0.1",
"@nestjs/common": "^10.2.8",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.2.8",
"@nestjs/mapped-types": "^2.0.3",
"@nestjs/microservices": "^10.2.8",
"@nestjs/platform-express": "^10.2.8",
"@nestjs/swagger": "^7.1.15",
"@nestjs/terminus": "^10.1.1",
"@prisma/client": "^5.6.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"express": "^4.17.3",
"husky": "^7.0.4",
"joi": "^17.6.0",
"jsonwebtoken": "^8.5.1",
"jwks-rsa": "^3.0.0",
"class-validator": "^0.14.0",
"joi": "^17.11.0",
"jsonwebtoken": "^9.0.2",
"jwks-rsa": "^3.1.0",
"liquibase": "^4.4.0",
"moment": "^2.29.1",
"nats": "^2.6.0",
"pg": "^8.7.3",
"prisma": "^3.9.2",
"moment": "^2.29.4",
"nats": "^2.18.0",
"pg": "^8.11.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"swagger-ui-express": "^4.3.0",
"winston": "^3.6.0",
"winston-elasticsearch": "^0.16.1"
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.0",
"winston": "^3.11.0",
"winston-elasticsearch": "^0.17.4"
},
"devDependencies": {
"@nestjs/cli": "^8.0.0",
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"dotenv-cli": "^4.1.1",
"eslint": "^8.0.1",
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"node-mocks-http": "^1.11.0",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.3.5"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"setupFiles": [
"<rootDir>/../setup.js"
],
"coveragePathIgnorePatterns": [
"<rootDir>/main",
"<rootDir>/client/",
"<rootDir>/common/"
],
"moduleNameMapper": {
"^@config/(.*)$": [
"<rootDir>/../config/$1"
],
"^@credentialDef/(.*)$": "<rootDir>/credentialDef/$1",
"^@issueCredential/(.*)$": "<rootDir>/issue-credential/$1",
"^@schemas/(.*)$": "<rootDir>/schemas/$1",
"^@userInfo/(.*)$": "<rootDir>/userInfo/$1",
"^@src/(.*)$": "<rootDir>/$1",
"^@DB/(.*)$": "<rootDir>/prisma/$1",
"^@common/(.*)$": "<rootDir>/common/$1",
"^@utils/(.*)$": "<rootDir>/utils/$1",
"^@health/(.*)$": "<rootDir>/health/$1"
},
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"@nestjs/cli": "^10.2.1",
"@nestjs/schematics": "^10.0.3",
"@nestjs/testing": "^10.2.8",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.96",
"@swc/jest": "^0.2.29",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.8",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.9.0",
"@types/supertest": "^2.0.16",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"dotenv-cli": "^7.3.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"node-mocks-http": "^1.13.0",
"prettier": "^3.1.0",
"prisma": "^5.6.0",
"rimraf": "^5.0.5",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
import { APP_FILTER } from '@nestjs/core';
import {
MiddlewareConsumer,
Module,
......@@ -6,16 +5,17 @@ import {
RequestMethod,
} from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_FILTER } from '@nestjs/core';
import { TerminusModule } from '@nestjs/terminus';
import config from '@config/config';
import validationSchema from '@config/validation';
import HealthController from '@src/health/health.controller';
import ExceptionHandler from '@src/common/exception.handler';
import SchemasModule from '@src/schemas/module';
import CredentialDefModule from '@src/credentialDef/module';
import UserInfoModule from '@userInfo/module';
import AttestationModule from './issue-credential/module';
import { AuthMiddleware } from './middleware/auth.middleware';
import ExceptionHandler from './common/exception.handler.js';
import config from './config/config.js';
import validationSchema from './config/validation.js';
import CredentialDefModule from './credentialDef/module.js';
import HealthController from './health/health.controller.js';
import AttestationModule from './issue-credential/module.js';
import { AuthMiddleware } from './middleware/auth.middleware.js';
import SchemasModule from './schemas/module.js';
import UserInfoModule from './userInfo/module.js';
@Module({
imports: [
......@@ -39,7 +39,6 @@ import { AuthMiddleware } from './middleware/auth.middleware';
],
})
export default class AppModule implements NestModule {
// eslint-disable-next-line class-methods-use-this
configure(consumer: MiddlewareConsumer) {
// eslint-disable-line
consumer
......
import { Inject, Injectable } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { lastValueFrom } from 'rxjs';
import { Connection, NATSServices } from '@common/constants';
import { Connection, NATSServices } from '../common/constants.js';
@Injectable()
export default class NatsClientService {
......
import { HttpService } from '@nestjs/axios';
import { Injectable } from '@nestjs/common';
import { lastValueFrom, map } from 'rxjs';
import { HttpService } from '@nestjs/axios';
@Injectable()
export default class RestClientService {
......
import {
natsAgentResponse,
natsConnectionResponse,
} from '../stubs/nats-response';
} from '../stubs/nats-response.js';
const NatsClientServiceMock = jest.fn().mockReturnValue({
getAgentByParticipantId: jest.fn().mockReturnValue(natsAgentResponse),
......
import schemaAgentDto from '@src/schemas/tests/stubs/schema-from-agent-dto';
import schemaAgentDto from '../../../schemas/tests/stubs/schema-from-agent-dto.js';
const RestClientServiceMock = jest.fn().mockReturnValue({
post: jest.fn().mockReturnValue({ agent: 'response' }),
......
import { PolicyReturnType } from '@src/client/tsa.client';
import { TSAService } from '@src/common/constants';
import { TSAService } from '../../../common/constants.js';
import { PolicyReturnType } from '../../tsa.client.js';
const TSAClientServiceMock = jest.fn().mockReturnValue({
getPolicy: jest.fn().mockImplementation((url: string) => {
......
import { HttpModule, HttpService } from '@nestjs/axios';
import { Test, TestingModule } from '@nestjs/testing';
import HttpServiceMock from '@src/tests/__mocks__/http-service';
import RestClientService from '../rest.client';
import HttpServiceMock from '../../tests/__mocks__/http-service.js';
import RestClientService from '../rest.client.js';
describe('RestClientService', () => {
let restClient: RestClientService;
......
import { ResponseType } from '@src/common/response';
import AttestationService from '@src/issue-credential/services/service';
import type { ResponseType } from '../../../common/response.js';
import AttestationService from '../../../issue-credential/services/service.js';
const natsAgentResponse: ResponseType = {
statusCode: 200,
......
import { Injectable } from '@nestjs/common';
import RestClientService from '@src/client/rest.client';
import RestClientService from './rest.client.js';
export interface PolicyReturnType {
success: boolean;
returnData?: any; // replace with actual structure when ready
returnData?: unknown; // replace with actual structure when ready
}
export interface PolicyResult {
allow: boolean;
data?: any;
data?: unknown;
}
@Injectable()
......@@ -35,7 +35,7 @@ export default class TSAClientService {
success: false,
returnData: 'Unable to fetch policy data.',
} as PolicyReturnType;
} catch (error: any) {
} catch (error: any /* eslint-disable-line @typescript-eslint/no-explicit-any */) {
let returnData = 'Something went wrong!';
if (error?.isAxiosError) {
......
import moment = require('moment');
import moment from 'moment';
const getDate = () => moment().format('MM-DD-YYYY, h:mm:ss a');
......
import {
ExceptionFilter,
Catch,
ArgumentsHost,
Catch,
ExceptionFilter,
HttpException,
HttpStatus,
} from '@nestjs/common';
import { HttpAdapterHost } from '@nestjs/core';
import { ResponseType } from './response';
import { ResponseType } from './response.js';
@Catch()
export default class ExceptionHandler implements ExceptionFilter {
constructor(private readonly httpAdapterHost: HttpAdapterHost) {}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
catch(exception: any, host: ArgumentsHost): void {
// In certain situations `httpAdapter` might not be available in the
// constructor method, thus we should resolve it here.
......@@ -25,10 +26,13 @@ export default class ExceptionHandler implements ExceptionFilter {
exception.message.error || exception.message || 'Something went wrong!';
if (exception instanceof HttpException) {
const errorResponse: any = exception.getResponse();
const errorResponse: string | object = exception.getResponse();
statusCode = exception.getStatus();
message = errorResponse.error || message;
message =
(typeof errorResponse === 'object' &&
Reflect.get(errorResponse, 'error')) ||
message;
}
const responseBody: ResponseType = {
......
export interface ResponseType {
statusCode: number;
message: string;
data?: any;
error?: any;
data?: unknown;
error?: unknown;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment