Skip to content
Snippets Groups Projects
Unverified Commit 9c1bde5b authored by Konstantin Tsabolov's avatar Konstantin Tsabolov
Browse files

chore: update dependencies, fix style

* Upgraded the dependencies to the latest versions
* Switched output to ESM format
* Switched NestJS and Jest to SWC to improve speed of building and testing
* Refactored TSConfig to remove tsconfig-paths
* Updated imports in all files to reflect the change in TSConfig
* Changed the linting rules (removed AirBnB config)
* Fixed Prettier installation (added ignore file)
* Fixed typing errors (mainly usage of any's)
* Fixed the non-working E2E test

P.S. None of the mentioned makes sense alone, therefore a huge commit :man_shrugging:
parent d4a791b9
No related branches found
No related tags found
2 merge requests!9feat(ssi): Establish a trusted connection with yourself,!8Project house-keeping, refactoring and reorganizing
Showing
with 309 additions and 258 deletions
......@@ -29,7 +29,7 @@ pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
**/logs/log.json
apps/**/logs/log.json
# OS
.DS_Store
......
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',
],
parserOptions: {
project: './tsconfig.json',
},
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',
'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
{
"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,115 +5,84 @@
"author": "Sagar",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"clean": "rm -r 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:dev": "nest start --watch --preserveWatchOutput",
"start:docker": "pnpm prisma:generate && pnpm dbSchema && pnpm start",
"start:docker:prod": "pnpm prisma:migrate && node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"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/cli": "^8.0.0",
"@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/schedule": "^1.0.2",
"@nestjs/schematics": "^8.0.0",
"@nestjs/swagger": "^5.2.0",
"@nestjs/terminus": "^8.0.4",
"@nestjs/testing": "^8.0.0",
"@prisma/client": "^3.15.2",
"@types/node": "^16.0.0",
"class-validator": "^0.13.2",
"express": "^4.17.3",
"joi": "^17.6.0",
"jsonwebtoken": "^8.5.1",
"jwks-rsa": "^3.0.0",
"moment": "^2.29.1",
"nats": "^2.6.0",
"prisma": "^3.15.2",
"@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.4",
"@nestjs/microservices": "^10.2.8",
"@nestjs/platform-express": "^10.2.8",
"@nestjs/schedule": "^4.0.0",
"@nestjs/swagger": "^7.1.16",
"@nestjs/terminus": "^10.1.1",
"@prisma/client": "^5.6.0",
"class-validator": "^0.14.0",
"joi": "^17.11.0",
"jsonwebtoken": "^9.0.2",
"jwks-rsa": "^3.1.0",
"moment": "^2.29.4",
"nats": "^2.18.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"simple-oauth2": "^5.0.0",
"winston": "^3.6.0",
"winston-elasticsearch": "^0.16.1"
"rxjs": "^7.8.1",
"winston": "^3.11.0",
"winston-elasticsearch": "^0.17.4"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@jest/globals": "^29.7.0",
"@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": "27.0.2",
"@types/jsonwebtoken": "^8.5.9",
"@types/simple-oauth2": "^4.1.1",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.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.26.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"jest": "^27.2.5",
"node-mocks-http": "^1.11.0",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"swagger-ui-express": "^4.3.0",
"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"
],
"coveragePathIgnorePatterns": [
"<rootDir>/main",
"<rootDir>/client"
],
"setupFiles": [
"<rootDir>/../setup.js"
],
"moduleNameMapper": {
"^@connections/(.*)$": "<rootDir>/connections/$1",
"^@src/(.*)$": "<rootDir>/$1",
"^@DB/(.*)$": "<rootDir>/prisma/$1",
"^@common/(.*)$": "<rootDir>/common/$1",
"@config/(.*)": [
"<rootDir>/../config/$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"
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.9.0",
"@types/simple-oauth2": "^5.0.7",
"@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-import": "^2.29.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-workspaces": "^0.9.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"node-mocks-http": "^1.13.0",
"prettier": "^3.1.0",
"prisma": "^5.6.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"swagger-ui-express": "^5.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import AppModule from './app.module';
import type { INestApplication } from '@nestjs/common';
import type { TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import AppModule from './app.module.js';
describe('App Module', () => {
let app: INestApplication;
......
import PrismaService from '@src/prisma/prisma.service';
import { APP_FILTER } from '@nestjs/core';
import {
MiddlewareConsumer,
Module,
NestModule,
RequestMethod,
} from '@nestjs/common';
import type { MiddlewareConsumer, NestModule } from '@nestjs/common';
import { Module, RequestMethod } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TerminusModule } from '@nestjs/terminus';
import validationSchema from '@config/validation';
import config from '@config/config';
import HealthController from '@health/health.controller';
import ExceptionHandler from '@common/exception.handler';
import ConnectionsModule from '@connections/module';
import { APP_FILTER } from '@nestjs/core';
import { ScheduleModule } from '@nestjs/schedule';
import SchedulerService from './connections/scheduler/scheduler.service';
import { AuthMiddleware } from './middleware/auth.middleware';
import { TerminusModule } from '@nestjs/terminus';
import ExceptionHandler from './common/exception.handler.js';
import config from './config/config.js';
import validationSchema from './config/validation.js';
import ConnectionsModule from './connections/module.js';
import SchedulerService from './connections/scheduler/scheduler.service.js';
import HealthController from './health/health.controller.js';
import { AuthMiddleware } from './middleware/auth.middleware.js';
import PrismaModule from './prisma/prisma.module.js';
@Module({
imports: [
......@@ -27,6 +22,7 @@ import { AuthMiddleware } from './middleware/auth.middleware';
load: [config],
validationSchema,
}),
PrismaModule,
ConnectionsModule,
],
controllers: [HealthController],
......@@ -36,7 +32,6 @@ import { AuthMiddleware } from './middleware/auth.middleware';
useClass: ExceptionHandler,
},
SchedulerService,
PrismaService,
],
})
export default class AppModule implements NestModule {
......
import logger from '@src/utils/logger';
import { Inject, Injectable } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { lastValueFrom } from 'rxjs';
import {
Attestation,
NATSServices,
Principal,
Attestation,
ProofManager,
} from '@common/constants';
import ResponseType from '@common/response';
import ConnectionSubscriptionEndpointDto from '@connections/entities/connectionSubscribeEndPoint.entity';
} from '../common/constants.js';
import type ResponseType from '../common/response.js';
import type ConnectionSubscriptionEndpointDto from '../connections/entities/connectionSubscribeEndPoint.entity.js';
import logger from '../utils/logger.js';
@Injectable()
export default class NatsClientService {
......
import StatusCode from './status.codes';
describe('StatusCode', () => {
it('should be defined', () => {
expect(StatusCode).toBeDefined();
});
});
import moment = require('moment');
import moment from 'moment';
const getDate = () => moment().format('MM-DD-YYYY, h:mm:ss a');
......
import {
ExceptionFilter,
Catch,
ArgumentsHost,
HttpException,
HttpStatus,
} from '@nestjs/common';
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
import { Catch, HttpException, HttpStatus } from '@nestjs/common';
import { HttpAdapterHost } from '@nestjs/core';
import ResponseType from './response';
import type 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 +21,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 default interface ResponseType {
statusCode: number;
message: string;
data?: any;
error?: any;
data?: unknown;
error?: unknown;
}
import { fileURLToPath } from 'node:url';
const parentDirectory = fileURLToPath(new URL('..', import.meta.url));
const config = () => ({
PORT: Number(process.env.PORT),
APP_URL: process.env.CONNECTION_MANAGER_URL,
......@@ -19,7 +23,7 @@ const config = () => ({
port: 5432,
synchronize: false,
logging: false,
entities: [`${__dirname}/../**/**.model{.ts,.js}`],
entities: [`${parentDirectory}/../**/**.model{.ts,.js}`],
DATABASE_URL: process.env.DATABASE_URL,
},
agent: {
......
import * as Joi from 'joi';
import Joi from 'joi';
const validationSchema = Joi.object({
DATABASE_URL: Joi.string().required(),
......
import { HttpModule } from '@nestjs/axios';
import { HttpStatus } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ConfigModule } from '@nestjs/config';
import { HttpModule } from '@nestjs/axios';
import NatsClientService from '@src/client/nats.client';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { NATSServices } from '@src/common/constants';
import httpMocks = require('node-mocks-http');
import RestClientService from '@src/client/rest.client';
import ConnectionsController from '@src/connections/controller/controller';
import ConnectionsService from '../services/service';
import PrismaService from '../../prisma/prisma.service';
import ConnectionStateDto from '../entities/connectionStateDto.entity';
import type { TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import httpMocks from 'node-mocks-http';
import NatsClientService from '../../client/nats.client.js';
import RestClientService from '../../client/rest.client.js';
import { NATSServices } from '../../common/constants.js';
import PrismaService from '../../prisma/prisma.service.js';
import type ConnectionStateDto from '../entities/connectionStateDto.entity.js';
import ConnectionsService from '../services/service.js';
import ConnectionsController from './controller.js';
describe('ConnectionsController', () => {
let connectionController: ConnectionsController;
......@@ -87,16 +89,18 @@ describe('ConnectionsController', () => {
};
const response = httpMocks.createResponse();
jest
.spyOn(connectionService, 'findConnections')
.mockResolvedValueOnce(serviceResult);
const res: any = await connectionController.getConnection(
param,
query,
response,
);
// eslint-disable-next-line no-underscore-dangle
const resData = res._getData();
expect(res.statusCode).toBe(HttpStatus.OK);
expect(JSON.parse(resData).data).toStrictEqual(result);
});
......@@ -124,16 +128,14 @@ describe('ConnectionsController', () => {
];
const response = httpMocks.createResponse();
jest
.spyOn(connectionService, 'findConnections')
.mockResolvedValueOnce(serviceResult);
const res: any = await connectionController.getConnection(
param,
query,
response,
);
// eslint-disable-next-line no-underscore-dangle
const res = await connectionController.getConnection(param, response);
const resData = res._getData();
expect(res.statusCode).toBe(HttpStatus.BAD_REQUEST);
expect(JSON.parse(resData).message).toStrictEqual(
'Participant ID/ connection ID / participant DID must be provided',
......@@ -191,7 +193,7 @@ describe('ConnectionsController', () => {
expect(JSON.parse(resData)).toStrictEqual(result);
});
it('Not fount if data is not present against connection id ', async () => {
it('Not fount if data is not present against connection id', async () => {
const param = {
connectionId: '7b821264-2ae3-4459-b45f-19fa975d91f7',
};
......@@ -345,66 +347,6 @@ describe('ConnectionsController', () => {
// expect(JSON.parse(resData).data).toStrictEqual(result);
});
it('Create connection webhook call', async () => {
const webHook: ConnectionStateDto = {
_tags: {},
metadata: {},
id: '7edc871d-9fa3-4f30-8763-59c80bf346f5',
createdAt: '2022-04-21T10:52:27.151Z',
did: 'DD8Aue5tuohjBaCLM9GMU7',
didDoc: {
'@context': 'https://w3id.org/did/v1',
publicKey: [
[
{
id: 'C1buxAXWiisjFpVVyUGM5D#1',
controller: 'C1buxAXWiisjFpVVyUGM5D',
type: 'Ed25519VerificationKey2018',
publicKeyBase58: '714U4GdQqyeqhCANgJmTrGqUPg4QTGuEhJcEGYAvEH1Y',
},
],
],
service: [
{
id: 'C1buxAXWiisjFpVVyUGM5D#IndyAgentService',
serviceEndpoint: 'http://localhost:4011',
type: 'IndyAgent',
priority: 0,
recipientKeys: ['714U4GdQqyeqhCANgJmTrGqUPg4QTGuEhJcEGYAvEH1Y'],
routingKeys: [],
},
],
authentication: [[Object]],
id: 'DD8Aue5tuohjBaCLM9GMU7',
},
theirDid: '',
theirLabel: '',
verkey: '7exBgFhenY8hqBwBF56D8sp6akLstqXxS1MUUCpDErvX',
state: 'invited',
role: 'inviter',
alias: 'member',
invitation: {
'@type': 'https://didcomm.org/connections/1.0/invitation',
'@id': '8578735f-eef8-4748-b791-ba2f8f7002e2',
label: 'State_University',
recipientKeys: ['7exBgFhenY8hqBwBF56D8sp6akLstqXxS1MUUCpDErvX'],
serviceEndpoint: 'http://localhost:4017',
routingKeys: [],
},
multiUseInvitation: false,
};
const serviceResult: any = {};
jest
.spyOn(connectionService, 'createConnections')
.mockResolvedValueOnce(serviceResult);
const res: any = await connectionController.createConnection({
body: webHook,
});
expect(res.statusCode).toBe(HttpStatus.CREATED);
// expect(JSON.parse(resData).data).toStrictEqual(result);
});
it('Update connection webhook call -> member flow', async () => {
const webHook: ConnectionStateDto = {
_tags: {},
......@@ -608,7 +550,7 @@ describe('ConnectionsController', () => {
multiUseInvitation: false,
};
const restConnection: any = {
const restConnection = {
id: '29701e41-60e8-4fca-8504-ea3bcefa6486',
connectionId: '72534911-9be0-4e3f-8539-2a8a09e4e409',
participantId: '662dc769-a4de-4c95-934c-f6dab8cf432c',
......@@ -620,7 +562,8 @@ describe('ConnectionsController', () => {
updatedDate: '2022-04-15T11:36:58.560Z',
isActive: true,
};
const serviceResult: any = {};
const serviceResult = {};
jest
.spyOn(connectionService, 'updateStatusByConnectionId')
.mockResolvedValueOnce(serviceResult);
......@@ -628,7 +571,7 @@ describe('ConnectionsController', () => {
jest
.spyOn(connectionService, 'getConnectionByID')
.mockResolvedValueOnce(restConnection);
const res: any = await connectionController.createConnection({
const res = await connectionController.createConnection({
body: webHook,
});
......@@ -637,7 +580,7 @@ describe('ConnectionsController', () => {
});
});
describe('Get invitation URL ', () => {
describe('Get invitation URL', () => {
it('Get Member invitation URL', async () => {
const body = {
autoAcceptConnection: true,
......
import type ResponseType from '../../common/response.js';
import type ConnectionStateDto from '../entities/connectionStateDto.entity.js';
import type ConnectionSubscriptionEndpointDto from '../entities/connectionSubscribeEndPoint.entity.js';
import type ConnectionDto from '../entities/entity.js';
import {
Body,
Controller,
......@@ -9,8 +14,7 @@ import {
Res,
Version,
} from '@nestjs/common';
import ResponseType from '@common/response';
import ConnectionDto from '@connections/entities/entity';
import { MessagePattern } from '@nestjs/microservices';
import {
ApiBody,
ApiExcludeEndpoint,
......@@ -19,19 +23,17 @@ import {
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import ConnectionsService from '@connections/services/service';
import ConnectionStateDto from '@connections/entities/connectionStateDto.entity';
import ConnectionCreateInvitationDto from '@connections/entities/connectionCreateInvitationDto.entity';
import { Response } from 'express';
import logger from '@src/utils/logger';
import { MessagePattern } from '@nestjs/microservices';
import {
Abstraction,
NATSServices,
RECEIVED_CONNECTION_ALIAS,
} from '@src/common/constants';
import ConnectionSubscriptionEndpointDto from '../entities/connectionSubscribeEndPoint.entity';
import AcceptConnectionInvitationBody from '../entities/AcceptConnectionInvitationBody';
} from '../../common/constants.js';
import logger from '../../utils/logger.js';
import AcceptConnectionInvitationBody from '../entities/AcceptConnectionInvitationBody.js';
import ConnectionCreateInvitationDto from '../entities/connectionCreateInvitationDto.entity.js';
import ConnectionsService from '../services/service.js';
@ApiTags('Connections')
@Controller()
......@@ -129,7 +131,8 @@ export default class ConnectionsController {
@Post('invitation-url')
@ApiOperation({
summary: 'Create new connection invitation',
description: 'This call provides the capability to create new connection invitation by providing alias parameter for taht connection in the body of request. Alias can be one of value: trust/subscriber/trust. This call returns an object contains three fields. invitationUrl, invitationUrlShort, invitation object and connection object. You can use invitationUrlShort or invitationUrl to create QR code which can be scanned by PCM. It\'s better to use invitationUrlShort because long string of invitationUrl replaced with short id and QR code can be displayed properly'
description:
"This call provides the capability to create new connection invitation by providing alias parameter for taht connection in the body of request. Alias can be one of value: trust/subscriber/trust. This call returns an object contains three fields. invitationUrl, invitationUrlShort, invitation object and connection object. You can use invitationUrlShort or invitationUrl to create QR code which can be scanned by PCM. It's better to use invitationUrlShort because long string of invitationUrl replaced with short id and QR code can be displayed properly",
})
@ApiResponse({
status: HttpStatus.OK,
......@@ -250,7 +253,7 @@ export default class ConnectionsController {
@ApiQuery({ name: 'alias', required: true })
async createConnectionInvitation(
@Body() connectionCreate: ConnectionCreateInvitationDto,
@Query() query,
@Query() query: { alias: string },
@Res() response: Response,
) {
logger.info(JSON.stringify(query));
......@@ -298,10 +301,13 @@ export default class ConnectionsController {
@Get('url/:id')
@ApiOperation({
summary: 'Get full url from short url id',
description: 'Get full url from short url id'
description: 'Get full url from short url id',
})
@ApiExcludeEndpoint()
async redirectToConnectionUrl(@Param() params, @Res() response: Response) {
async redirectToConnectionUrl(
@Param() params: { id: string },
@Res() response: Response,
) {
const result = await this.connectionsService.findConnectionByShortUrlId(
params.id,
);
......@@ -318,7 +324,8 @@ export default class ConnectionsController {
@Get('connection-information')
@ApiOperation({
summary: 'Fetch connection information by id or did',
description: 'This call provides the capability to get information about connection by connectionId or did. This call returns issued credentials and requested proof to that connection'
description:
'This call provides the capability to get information about connection by connectionId or did. This call returns issued credentials and requested proof to that connection',
})
@ApiQuery({ name: 'connectionId', required: false })
@ApiQuery({ name: 'did', required: false })
......@@ -393,7 +400,7 @@ export default class ConnectionsController {
},
})
async getConnectionInformationRequest(
@Query() query,
@Query() query: { connectionId: string; did: string },
@Res() response: Response,
) {
let res: ResponseType;
......@@ -436,7 +443,8 @@ export default class ConnectionsController {
@Get('connections')
@ApiOperation({
summary: 'Fetch list of connections',
description: 'This call provides the capability to search connections by using pagination and filter parameters. This call returns a list of connections and overall count of records. This endpoint supports followinng query filter parameters: participantDID, status, pageSize, page'
description:
'This call provides the capability to search connections by using pagination and filter parameters. This call returns a list of connections and overall count of records. This endpoint supports followinng query filter parameters: participantDID, status, pageSize, page',
})
@ApiQuery({ name: 'page', required: false })
@ApiQuery({ name: 'pageSize', required: false })
......@@ -494,8 +502,14 @@ export default class ConnectionsController {
},
})
async getConnectionLists(
@Param() params,
@Query() query,
@Param() params: { connectionId: string },
@Query()
query: {
participantDID?: string;
pageSize?: string;
page?: string;
status?: string;
},
@Res() response: Response,
) {
let res: ResponseType;
......@@ -504,7 +518,7 @@ export default class ConnectionsController {
query.pageSize ? parseInt(query.pageSize, 10) : 10,
query.page ? parseInt(query.page, 10) : 0,
query.status ? query.status : false,
params?.connectionId ? params.connectionId : null,
params?.connectionId ? params.connectionId : undefined,
query.participantDID,
);
......@@ -539,12 +553,12 @@ export default class ConnectionsController {
return response.json(res);
}
@Version(['1'])
@Get('connections/:connectionId')
@ApiOperation({
summary: 'Fetch connection by id',
description: 'This call provides the capability to get connection data by providing connectionId. The connection data is the same which is returned from /v1/connections endpoint and contains generic information about connection like connectionId, status, dids and so on.'
description:
'This call provides the capability to get connection data by providing connectionId. The connection data is the same which is returned from /v1/connections endpoint and contains generic information about connection like connectionId, status, dids and so on.',
})
@ApiResponse({
status: HttpStatus.OK,
......@@ -598,14 +612,10 @@ export default class ConnectionsController {
},
})
async getConnection(
@Param() params,
@Param() params: { connectionId: string },
@Res() response: Response,
) {
return this.getConnectionLists(
params,
{},
response
);
return this.getConnectionLists(params, {}, response);
}
@MessagePattern({
......@@ -636,7 +646,8 @@ export default class ConnectionsController {
@Post('accept-connection-invitation')
@ApiOperation({
summary: 'Accept connection invitation',
description: 'This call provides the capability to receive connection invitation as invitee by invitationUrl and create connection. If auto accepting is enabled via either the config passed in the function or the global agent config, a connection request message will be send.'
description:
'This call provides the capability to receive connection invitation as invitee by invitationUrl and create connection. If auto accepting is enabled via either the config passed in the function or the global agent config, a connection request message will be send.',
})
@ApiResponse({
status: HttpStatus.ACCEPTED,
......
import { IsString, IsNotEmpty } from 'class-validator';
import InvitationDTO from './InvitationDto.entity';
import { IsBooleanString, IsNotEmpty, IsString } from 'class-validator';
import InvitationDTO from './InvitationDto.entity.js';
export default class ConnectionStateDto {
@IsString()
['_tags']?: any;
_tags?: string;
@IsString()
metadata?: any;
metadata?: string;
@IsString()
didDoc?: any;
didDoc?: string;
@IsString()
verkey?: string;
......@@ -45,5 +46,6 @@ export default class ConnectionStateDto {
@IsString()
alias: string;
@IsBooleanString()
multiUseInvitation?: boolean;
}
import { IsString, IsNotEmpty, IsDate, IsBoolean } from 'class-validator';
import InvitationDTO from './InvitationDto.entity';
import InvitationDTO from './InvitationDto.entity.js';
export default class ConnectionDto {
@IsString()
......
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