Skip to content

Commit cb36c19

Browse files
author
vinod
committed
login added
1 parent 71ef233 commit cb36c19

File tree

12 files changed

+376
-12
lines changed

12 files changed

+376
-12
lines changed

package-lock.json

Lines changed: 218 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"dependencies": {
2222
"@nestjs/common": "10.2.6",
2323
"@nestjs/core": "10.2.6",
24-
"@nestjs/mongoose": "^10.0.1",
24+
"@nestjs/jwt": "^10.2.0",
25+
"@nestjs/mongoose": "^10.0.2",
2526
"@nestjs/platform-express": "10.2.6",
2627
"bcrypt": "^5.1.1",
2728
"class-transformer": "^0.5.1",

src/app.module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Module } from '@nestjs/common';
22
import { MongooseModule } from '@nestjs/mongoose';
33
import { UserModule } from './users/users.module';
4-
4+
import { AuthModule } from './auth/auth.module'
55
@Module({
66
imports: [
77
MongooseModule.forRoot('mongodb://localhost:27017/test'),
8-
UserModule
9-
],
8+
UserModule,
9+
AuthModule
10+
]
1011
})
1112
export class AppModule {}

src/auth/auth.controller.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
Body,
3+
Controller,
4+
Get,
5+
HttpCode,
6+
HttpStatus,
7+
Post,
8+
Request,
9+
} from '@nestjs/common';
10+
import { AuthService } from './auth.service';
11+
import { Public } from './decorators/public.decorator';
12+
13+
@Controller('auth')
14+
export class AuthController {
15+
constructor(private authService: AuthService) {}
16+
17+
@Public()
18+
@HttpCode(HttpStatus.OK)
19+
@Post('login')
20+
signIn(@Body() signInDto: Record<string, any>) {
21+
22+
return this.authService.signIn(signInDto.email, signInDto.password);
23+
}
24+
25+
@Get('profile')
26+
getProfile(@Request() req) {
27+
return req.user;
28+
}
29+
}

0 commit comments

Comments
 (0)