-
Notifications
You must be signed in to change notification settings - Fork 0
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
25 changed files
with
277 additions
and
187 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 80, | ||
"tabWidth": 4, | ||
"semi": false, | ||
"arrowParens": "avoid", | ||
"endOfLine": "auto" | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 80, | ||
"tabWidth": 4, | ||
"semi": true, | ||
"arrowParens": "avoid", | ||
"endOfLine": "auto" | ||
} |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
{ | ||
"search.exclude": { | ||
"**/.yarn": true, | ||
"**/.pnp.*": true | ||
}, | ||
"eslint.nodePath": ".yarn/sdks", | ||
"prettier.prettierPath": ".yarn/sdks/prettier/index.js", | ||
"typescript.tsdk": ".yarn/sdks/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true | ||
"search.exclude": { | ||
"**/.yarn": true, | ||
"**/.pnp.*": true | ||
}, | ||
"eslint.nodePath": ".yarn/sdks", | ||
"prettier.prettierPath": ".yarn/sdks/prettier/index.js", | ||
"typescript.tsdk": ".yarn/sdks/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"cSpell.words": ["ectx"] | ||
} |
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
|
||
import { AppController } from './app.controller' | ||
import { AppService } from './app.service' | ||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
|
||
describe('AppController', () => { | ||
let app: TestingModule | ||
let app: TestingModule; | ||
|
||
beforeAll(async () => { | ||
app = await Test.createTestingModule({ | ||
controllers: [AppController], | ||
providers: [AppService], | ||
}).compile() | ||
}) | ||
}).compile(); | ||
}); | ||
|
||
describe('getData', () => { | ||
it('should return "Hello World!"', () => { | ||
const appController = app.get<AppController>(AppController) | ||
const appController = app.get<AppController>(AppController); | ||
expect(appController.getHello()).toEqual({ | ||
message: '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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { Controller, Get } from '@nestjs/common' | ||
import { Controller, Get } from '@nestjs/common'; | ||
|
||
import { AppService } from './app.service' | ||
import { AppService } from './app.service'; | ||
|
||
@Controller() | ||
export class AppController { | ||
constructor(private readonly appService: AppService) {} | ||
|
||
@Get() | ||
getHello() { | ||
return this.appService.getHello() | ||
return this.appService.getHello(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { Test } from '@nestjs/testing' | ||
import { Test } from '@nestjs/testing'; | ||
|
||
import { AppService } from './app.service' | ||
import { AppService } from './app.service'; | ||
|
||
describe('AppService', () => { | ||
let service: AppService | ||
let service: AppService; | ||
|
||
beforeAll(async () => { | ||
const app = await Test.createTestingModule({ | ||
providers: [AppService], | ||
}).compile() | ||
}).compile(); | ||
|
||
service = app.get<AppService>(AppService) | ||
}) | ||
service = app.get<AppService>(AppService); | ||
}); | ||
|
||
describe('getHello', () => { | ||
it('should return "Hello API"', () => { | ||
expect(service.getHello()).toEqual({ message: 'Hello API' }) | ||
}) | ||
}) | ||
}) | ||
expect(service.getHello()).toEqual({ message: 'Hello API' }); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { Injectable } from '@nestjs/common' | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class AppService { | ||
getHello() { | ||
return { | ||
message: '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 |
---|---|---|
@@ -1,32 +1,21 @@ | ||
// auth.module.ts | ||
import { Module } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { JwtModule } from '@nestjs/jwt'; | ||
import { MongooseModule } from '@nestjs/mongoose'; | ||
import { PassportModule } from '@nestjs/passport'; | ||
|
||
import { AuthController } from './auth.controller'; | ||
import { AuthService } from './auth.service'; | ||
import { JwtConfigModule } from './jwt.config.module'; | ||
import { JwtStrategy } from './jwt.strategy'; | ||
import { User, UserSchema } from './schemas/user.schema'; | ||
import { authProviders } from './providers'; | ||
import { UserModule } from './user.module'; | ||
|
||
@Module({ | ||
imports: [ | ||
PassportModule.register({ defaultStrategy: 'jwt' }), | ||
JwtModule.registerAsync({ | ||
inject: [ConfigService], | ||
useFactory: async (configService: ConfigService) => ({ | ||
secret: configService.get<string>('JWT_SECRET'), | ||
signOptions: { | ||
expiresIn: configService.get<string | number>( | ||
'JWT_EXPIRES_IN', | ||
), | ||
}, | ||
}), | ||
}), | ||
MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]), | ||
JwtConfigModule, | ||
UserModule, | ||
], | ||
controllers: [AuthController], | ||
providers: [AuthService, JwtStrategy], | ||
providers: [...authProviders], | ||
exports: [JwtStrategy, PassportModule], | ||
}) | ||
export class AuthModule {} |
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
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 |
---|---|---|
|
@@ -18,6 +18,4 @@ export class LoginDto { | |
example: 'Abcd@1234', | ||
}) | ||
password: string; | ||
|
||
// email?: | ||
} |
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,19 @@ | ||
export interface SignupInfo { | ||
phone: string; | ||
password: string; | ||
name: string; | ||
} | ||
|
||
export interface LoginInfo { | ||
phone: string; | ||
password: string; | ||
} | ||
|
||
export interface JwtPayload { | ||
user_id: string; | ||
} | ||
|
||
export enum AuthError { | ||
PhoneAlreadyInUse = 'phone number already in use', | ||
InvalidCredentials = 'Invalid credentials', | ||
} |
Oops, something went wrong.