-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AppAuthService } from './services/app-auth/app-auth.service'; | ||
import { AppAuthController } from './controllers/app-auth/app-auth.controller'; | ||
|
||
@Module({ | ||
providers: [AppAuthService], | ||
controllers: [AppAuthController] | ||
}) | ||
export class AppAuthModule {} |
18 changes: 18 additions & 0 deletions
18
src/app-auth/controllers/app-auth/app-auth.controller.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { AppAuthController } from './app-auth.controller'; | ||
|
||
describe('AppAuthController', () => { | ||
let controller: AppAuthController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [AppAuthController], | ||
}).compile(); | ||
|
||
controller = module.get<AppAuthController>(AppAuthController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
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 { Controller, Get, ValidationPipe, Post, UsePipes, Body, Req, Res, HttpStatus } from '@nestjs/common'; | ||
import { CreateAppDto } from 'src/app-auth/dtos/CreateApp.dto'; | ||
import { AppAuthService } from 'src/app-auth/services/app-auth/app-auth.service'; | ||
import { Request, Response } from 'express' | ||
@Controller('app-auth') | ||
export class AppAuthController { | ||
constructor(private readonly appAuthService: AppAuthService){} | ||
|
||
@Get() | ||
getAppAuth() { | ||
return this.appAuthService.getAllApps(); | ||
} | ||
|
||
|
||
@Post('/register') | ||
register(@Req() req: Request,@Res() res: Response): any { | ||
|
||
console.log(req.body) | ||
const b = new CreateAppDto() | ||
b.userId = req.body['userId']; | ||
b.appName = req.body['appName']; | ||
const napp = this.appAuthService.createAnApp(b) | ||
return res.status(HttpStatus.CREATED).send(napp) | ||
} | ||
|
||
} |
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,5 @@ | ||
|
||
export class CreateAppDto { | ||
userId: string; | ||
appName: 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,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { AppAuthService } from './app-auth.service'; | ||
|
||
describe('AppAuthService', () => { | ||
let service: AppAuthService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [AppAuthService], | ||
}).compile(); | ||
|
||
service = module.get<AppAuthService>(AppAuthService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
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,32 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { IApp } from '../../types/App.types'; | ||
import { CreateAppDto } from '../../dtos/CreateApp.dto'; | ||
@Injectable() | ||
export class AppAuthService { | ||
private apps = [ | ||
{ | ||
userId: "user123", | ||
appName: "app1", | ||
appId: "app-1", | ||
appSecret: "app-secret-1", | ||
edvId: "edv-1", | ||
kmsId: "kms-1", | ||
} | ||
] | ||
|
||
createAnApp(createAppDto: CreateAppDto){ | ||
const newApp = { | ||
...createAppDto, | ||
appId: 'app-1', | ||
appSecret: "app-secret-1", | ||
edvId: "edv-1", | ||
kmsId: "kms-1", | ||
} | ||
this.apps.push(newApp); | ||
return newApp | ||
} | ||
|
||
getAllApps () { | ||
return this.apps | ||
} | ||
} |
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,8 @@ | ||
export interface IApp { | ||
userId: string; | ||
appName: string; | ||
appId: string; | ||
appSecret: string; | ||
edvId: string; | ||
kmsId: string; | ||
} |