-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* worked on the master table json file and .env sample refractoring Signed-off-by: @nishad.shirsat <[email protected]> * merge dev branch to main (#77) * fix: Changed the passkey approch Signed-off-by: KulkarniShashank <[email protected]> * feat/fix: Implemented Add passkey for existing users Signed-off-by: tipusinghaw <[email protected]> * feat:implemented add passke Signed-off-by: tipusinghaw <[email protected]> * fix: login error message Signed-off-by: tipusinghaw <[email protected]> --------- Signed-off-by: KulkarniShashank <[email protected]> Signed-off-by: tipusinghaw <[email protected]> * Included credebl-master-table json file in the .gitignore Signed-off-by: @nishad.shirsat <[email protected]> * Create ecosystem monorepo Signed-off-by: KulkarniShashank <[email protected]> * feat: Implemented ecosystem microservice Signed-off-by: tipusinghaw <[email protected]> * feat: changed controller name Signed-off-by: tipusinghaw <[email protected]> --------- Signed-off-by: tipusinghaw <[email protected]> Signed-off-by: @nishad.shirsat <[email protected]> Signed-off-by: KulkarniShashank <[email protected]> Co-authored-by: Nishad Shirsat <[email protected]> Co-authored-by: @nishad.shirsat <[email protected]> Co-authored-by: Shashank Kulkarni <[email protected]> Co-authored-by: KulkarniShashank <[email protected]> Signed-off-by: KulkarniShashank <[email protected]>
- Loading branch information
1 parent
6154299
commit c1c3bbe
Showing
15 changed files
with
310 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
apps/api-gateway/src/ecosystem/dtos/create-organization-dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ApiExtraModels, ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsOptional, IsString, MaxLength, MinLength } from 'class-validator'; | ||
|
||
import { Transform } from 'class-transformer'; | ||
import { trim } from '@credebl/common/cast.helper'; | ||
|
||
@ApiExtraModels() | ||
export class CreateEcosystemDto { | ||
|
||
@ApiProperty() | ||
@Transform(({ value }) => trim(value)) | ||
@IsNotEmpty({ message: 'Organization name is required.' }) | ||
@MinLength(2, { message: 'Organization name must be at least 2 characters.' }) | ||
@MaxLength(50, { message: 'Organization name must be at most 50 characters.' }) | ||
@IsString({ message: 'Organization name must be in string format.' }) | ||
name: string; | ||
|
||
@ApiPropertyOptional() | ||
@Transform(({ value }) => trim(value)) | ||
@MinLength(2, { message: 'Description must be at least 2 characters.' }) | ||
@MaxLength(255, { message: 'Description must be at most 255 characters.' }) | ||
@IsString({ message: 'Description must be in string format.' }) | ||
description: string; | ||
|
||
@ApiPropertyOptional() | ||
@IsOptional() | ||
@Transform(({ value }) => trim(value)) | ||
@IsString({ message: 'logo must be in string format.' }) | ||
logo: string; | ||
|
||
@ApiPropertyOptional() | ||
@IsOptional() | ||
@Transform(({ value }) => trim(value)) | ||
website?: string; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ApiBearerAuth, ApiForbiddenResponse, ApiOperation, ApiResponse, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger'; | ||
import { Controller, UseGuards, UseFilters } from '@nestjs/common'; | ||
import { EcosystemService } from './ecosystem.service'; | ||
import { Post } from '@nestjs/common'; | ||
import { Body } from '@nestjs/common'; | ||
import { Res } from '@nestjs/common'; | ||
import { CreateEcosystemDto } from './dtos/create-organization-dto'; | ||
import IResponseType from '@credebl/common/interfaces/response.interface'; | ||
import { HttpStatus } from '@nestjs/common'; | ||
import { Response } from 'express'; | ||
import { ApiResponseDto } from '../dtos/apiResponse.dto'; | ||
import { UnauthorizedErrorDto } from '../dtos/unauthorized-error.dto'; | ||
import { ForbiddenErrorDto } from '../dtos/forbidden-error.dto'; | ||
import { AuthGuard } from '@nestjs/passport'; | ||
import { ResponseMessages } from '@credebl/common/response-messages'; | ||
import { CustomExceptionFilter } from 'apps/api-gateway/common/exception-handler'; | ||
|
||
|
||
@UseFilters(CustomExceptionFilter) | ||
@Controller('ecosystem') | ||
@ApiTags('ecosystem') | ||
@ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized', type: UnauthorizedErrorDto }) | ||
@ApiForbiddenResponse({ status: 403, description: 'Forbidden', type: ForbiddenErrorDto }) | ||
export class EcosystemController { | ||
constructor( | ||
private readonly ecosystemService: EcosystemService | ||
) { } | ||
|
||
|
||
@Post('/') | ||
@ApiOperation({ summary: 'Create a new ecosystem', description: 'Create an ecosystem' }) | ||
@ApiResponse({ status: 201, description: 'Success', type: ApiResponseDto }) | ||
@UseGuards(AuthGuard('jwt')) | ||
@ApiBearerAuth() | ||
async createOrganization(@Body() createOrgDto: CreateEcosystemDto, @Res() res: Response): Promise<Response> { | ||
await this.ecosystemService.createEcosystem(createOrgDto); | ||
const finalResponse: IResponseType = { | ||
statusCode: HttpStatus.CREATED, | ||
message: ResponseMessages.ecosystem.success.create | ||
}; | ||
return res.status(HttpStatus.CREATED).json(finalResponse); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { CommonModule, CommonService } from '@credebl/common'; | ||
|
||
import { ClientsModule, Transport } from '@nestjs/microservices'; | ||
import { ConfigModule } from '@nestjs/config'; | ||
import { HttpModule } from '@nestjs/axios'; | ||
import { Module } from '@nestjs/common'; | ||
import { EcosystemController } from './ecosystem.controller'; | ||
import { EcosystemService } from './ecosystem.service'; | ||
|
||
@Module({ | ||
imports: [ | ||
HttpModule, | ||
ConfigModule.forRoot(), | ||
ClientsModule.register([ | ||
{ | ||
name: 'NATS_CLIENT', | ||
transport: Transport.NATS, | ||
options: { | ||
servers: [`${process.env.NATS_URL}`] | ||
} | ||
}, | ||
CommonModule | ||
]) | ||
], | ||
controllers: [EcosystemController], | ||
providers: [EcosystemService, CommonService] | ||
}) | ||
export class EcosystemModule { } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Inject } from '@nestjs/common'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { ClientProxy } from '@nestjs/microservices'; | ||
import { BaseService } from 'libs/service/base.service'; | ||
|
||
|
||
@Injectable() | ||
export class EcosystemService extends BaseService { | ||
constructor(@Inject('NATS_CLIENT') private readonly serviceProxy: ClientProxy) { | ||
super('EcosystemService'); | ||
} | ||
|
||
/** | ||
* | ||
* @param createEcosystemDto | ||
* @returns Ecosystem creation success | ||
*/ | ||
async createEcosystem(createEcosystemDto): Promise<object> { | ||
const payload = { createEcosystemDto }; | ||
return this.sendNats(this.serviceProxy, 'create-ecosystem', payload); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { EcosystemController } from './ecosystem.controller'; | ||
import { EcosystemService } from './ecosystem.service'; | ||
|
||
describe('EcosystemController', () => { | ||
let ecosystemController: EcosystemController; | ||
|
||
beforeEach(async () => { | ||
const app: TestingModule = await Test.createTestingModule({ | ||
controllers: [EcosystemController], | ||
providers: [EcosystemService] | ||
}).compile(); | ||
|
||
ecosystemController = app.get<EcosystemController>(EcosystemController); | ||
}); | ||
|
||
describe('root', () => { | ||
it('should return "Hello World!"', () => { | ||
expect(ecosystemController.getHello()).toBe('Hello World!'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Controller, Logger } from '@nestjs/common'; | ||
|
||
import { MessagePattern } from '@nestjs/microservices'; | ||
import { EcosystemService } from './ecosystem.service'; | ||
import { Body } from '@nestjs/common'; | ||
|
||
@Controller() | ||
export class EcosystemController { | ||
constructor(private readonly ecosystemService: EcosystemService) {} | ||
private readonly logger = new Logger('EcosystemController'); | ||
|
||
/** | ||
* Description: create new ecosystem | ||
* @param payload Registration Details | ||
* @returns Get created ecosystem details | ||
*/ | ||
|
||
@MessagePattern({ cmd: 'create-ecosystem' }) | ||
async createEcosystem(@Body() payload: { createOrgDto; userId }): Promise<string> { | ||
this.logger.log(`EcosystemPayload : ${payload}`); | ||
return this.ecosystemService.createEcosystem(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Logger, Module } from '@nestjs/common'; | ||
import { EcosystemController } from './ecosystem.controller'; | ||
import { EcosystemService } from './ecosystem.service'; | ||
import { ClientsModule, Transport } from '@nestjs/microservices'; | ||
import { CommonModule } from '@credebl/common'; | ||
// import { ConnectionRepository } from './connection.repository'; | ||
import { PrismaService } from '@credebl/prisma-service'; | ||
|
||
@Module({ | ||
imports: [ | ||
ClientsModule.register([ | ||
{ | ||
name: 'NATS_CLIENT', | ||
transport: Transport.NATS, | ||
options: { | ||
servers: [`${process.env.NATS_URL}`] | ||
} | ||
} | ||
]), | ||
|
||
CommonModule | ||
], | ||
controllers: [EcosystemController], | ||
providers: [EcosystemService, PrismaService, Logger] | ||
}) | ||
export class EcosystemModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// eslint-disable-next-line camelcase | ||
import { Injectable} from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class EcosystemService { | ||
constructor( | ||
) { } | ||
|
||
/** | ||
* | ||
* @param registerOrgDto | ||
* @returns | ||
*/ | ||
|
||
// eslint-disable-next-line camelcase | ||
async createEcosystem():Promise<string> { | ||
return "test"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { EcosystemModule } from './ecosystem.module'; | ||
import { HttpExceptionFilter } from 'libs/http-exception.filter'; | ||
import { Logger } from '@nestjs/common'; | ||
import { MicroserviceOptions, Transport } from '@nestjs/microservices'; | ||
|
||
const logger = new Logger(); | ||
|
||
async function bootstrap(): Promise<void> { | ||
|
||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(EcosystemModule, { | ||
transport: Transport.NATS, | ||
options: { | ||
servers: [`${process.env.NATS_URL}`] | ||
} | ||
}); | ||
|
||
app.useGlobalFilters(new HttpExceptionFilter()); | ||
|
||
await app.listen(); | ||
logger.log('Ecosystem microservice is listening to NATS '); | ||
} | ||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import * as request from 'supertest'; | ||
import { EcosystemModule } from './../src/ecosystem.module'; | ||
|
||
describe('EcosystemController (e2e)', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [EcosystemModule] | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
it('/ (GET)', () => { | ||
return request(app.getHttpServer()) | ||
.get('/') | ||
.expect(200) | ||
.expect('Hello World!'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"moduleFileExtensions": ["js", "json", "ts"], | ||
"rootDir": ".", | ||
"testEnvironment": "node", | ||
"testRegex": ".e2e-spec.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": false, | ||
"outDir": "../../dist/apps/ecosystem" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters