Skip to content

Commit

Permalink
'.'
Browse files Browse the repository at this point in the history
  • Loading branch information
ManucherKM committed Sep 21, 2023
1 parent dba2210 commit 0ffe630
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 5 deletions.
150 changes: 150 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@nestjs/config": "^3.1.0",
"@nestjs/core": "^9.0.0",
"@nestjs/mongoose": "^10.0.1",
"@nestjs/passport": "^10.0.2",
"@nestjs/platform-express": "^9.0.0",
"axios": "^1.5.0",
"bcrypt": "^5.1.1",
Expand All @@ -32,6 +33,7 @@
"mongoose": "^7.5.1",
"multer": "^1.4.5-lts.1",
"nodemailer": "^6.9.5",
"passport-jwt": "^4.0.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"uuid": "^9.0.1"
Expand All @@ -48,6 +50,7 @@
"@types/jsonwebtoken": "^9.0.2",
"@types/multer": "^1.4.7",
"@types/nodemailer": "^6.4.10",
"@types/passport-jwt": "^3.0.9",
"@types/supertest": "^2.0.11",
"@types/uuid": "^9.0.3",
"prettier": "^3.0.3",
Expand Down
10 changes: 9 additions & 1 deletion src/file/file.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { Controller, Post, UploadedFile, UseInterceptors } from '@nestjs/common'
import { JwtAuthGuard } from '@/guard/jwt-auth.guard'
import {
Controller,
Post,
UploadedFile,
UseGuards,
UseInterceptors,
} from '@nestjs/common'
import { FileInterceptor } from '@nestjs/platform-express'
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger'
import { FileService } from './file.service'
import { fileStorage } from './storage'

@ApiTags('File')
@UseGuards(JwtAuthGuard)
@Controller('file')
export class FileController {
constructor(private readonly fileService: FileService) {}
Expand Down
2 changes: 2 additions & 0 deletions src/file/file.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { JwtModule } from '@/jwt/jwt.module'
import { Module } from '@nestjs/common'
import { MongooseModule } from '@nestjs/mongoose'
import { File, FileSchema } from './entities/file.entity'
Expand All @@ -7,6 +8,7 @@ import { FileService } from './file.service'
@Module({
imports: [
MongooseModule.forFeature([{ name: File.name, schema: FileSchema }]),
JwtModule,
],
controllers: [FileController],
providers: [FileService],
Expand Down
2 changes: 0 additions & 2 deletions src/google-user/google-user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { JwtAuthGuard } from '@/guard/jwt-auth.guard'
import {
Body,
Controller,
Expand All @@ -15,7 +14,6 @@ import { CreateGoogleUserDto } from './dto/create-google-user.dto'
import { GoogleUserService } from './google-user.service'

@ApiTags('Google User')
@UseGuards(JwtAuthGuard)
@Controller('google-user')
export class GoogleUserController {
constructor(private readonly googleUserService: GoogleUserService) {}
Expand Down
6 changes: 4 additions & 2 deletions src/guard/jwt-auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ export class JwtAuthGuard implements CanActivate {

async canActivate(context: ExecutionContext): Promise<boolean> {
const req: Request = context.switchToHttp().getRequest()
const token = req.headers.authorization.split(' ')[1]
const token = req.headers.authorization?.split(' ')[1]

console.log(token)
if (!token) {
return false
}

const [isValid] = await this.jwtService.validateToken('access', token)

Expand Down

0 comments on commit 0ffe630

Please sign in to comment.