Skip to content

Commit

Permalink
fix: 환경 변수를 읽지 못하는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
minjungw00 committed Nov 17, 2024
1 parent 0f071e9 commit 21c442b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion server/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ export class AuthController {
@Post("register")
async register(@Body() body: { email: string; password: string; name: string }) {
const { email, password, name } = body;
return this.authService.register(email, password, name);
const user = await this.authService.register(email, password, name);
return {
id: user.id,
email: user.email,
name: user.name,
};
}

@Post("login")
Expand Down
13 changes: 10 additions & 3 deletions server/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ import { AuthController } from "./auth.controller";
import { JwtModule } from "@nestjs/jwt";
import { PassportModule } from "@nestjs/passport";
import { JwtStrategy } from "./jwt.strategy";
import { ConfigModule, ConfigService } from "@nestjs/config";

@Module({
imports: [
MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]),
PassportModule,
JwtModule.register({
secret: process.env.JWT_SECRET,
signOptions: { expiresIn: "1h" },
JwtModule.registerAsync({
global: true,
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
secret: config.get<string>("JWT_SECRET"),
signOptions: { expiresIn: "1h" },
}),
}),
],
exports: [AuthService, JwtModule],
providers: [AuthService, JwtStrategy],
controllers: [AuthController],
})
Expand Down

0 comments on commit 21c442b

Please sign in to comment.