-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/logger
- Loading branch information
Showing
48 changed files
with
648 additions
and
396 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -110,3 +110,8 @@ postgres/ | |
|
||
# Migrations | ||
**/database/migrations/* | ||
|
||
======= | ||
# Local Uploads | ||
/backend/uploads/* | ||
data |
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,24 +1,13 @@ | ||
################### | ||
# BUILD FOR LOCAL DEVELOPMENT | ||
################### | ||
FROM node:18 | ||
|
||
# Base image | ||
FROM node:18 AS development | ||
WORKDIR /usr/src/app/server | ||
|
||
# Set working directory | ||
WORKDIR /usr/src/app | ||
COPY . . | ||
|
||
# Copy package.json and package-lock.json | ||
COPY --chown=node:node package*.json ./ | ||
RUN npm install | ||
RUN npm run build | ||
|
||
# Install dependencies | ||
RUN npm ci | ||
RUN npm install -g @nestjs/cli | ||
EXPOSE 3000 | ||
|
||
# Copy source code | ||
COPY --chown=node:node . . | ||
CMD [ "npm", "run", "start" ] | ||
|
||
# Generate Prisma database client code | ||
RUN npm run prisma:generate | ||
|
||
ENTRYPOINT [ "npm", "run", "start:dev" ] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
7 changes: 2 additions & 5 deletions
7
.devcontainer/postCreateCommand.sh → backend/scripts/postCreateCommand.sh
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,16 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Install dependencies | ||
cd backend/ && npm ci | ||
cd backend/ && npm i | ||
|
||
# Install NestJS CLI | ||
npm install -g @nestjs/cli | ||
|
||
# Generate Prisma Client | ||
npm run prisma:generate | ||
npx prisma generate | ||
|
||
# Generate Prisma Migrations | ||
npx prisma db push --force-reset && npx prisma db seed | ||
|
||
# Docker daemon setup | ||
sudo chown node:node /var/run/docker.sock |
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
Controller, | ||
Post, | ||
Patch, | ||
Delete, | ||
UseInterceptors, | ||
UploadedFile, | ||
ParseFilePipe, | ||
MaxFileSizeValidator, | ||
UseGuards, | ||
Req, | ||
} from '@nestjs/common'; | ||
import { AvatarUploadService } from './avatar-upload.service'; | ||
import { FileInterceptor } from '@nestjs/platform-express'; | ||
import { AccessTokenGuard } from 'src/auth/jwt/jwt.guard'; | ||
import { User } from '@prisma/client'; | ||
|
||
const fileValidators = [ | ||
new MaxFileSizeValidator({ | ||
// 1MB | ||
maxSize: 1024 * 1024, | ||
}), | ||
]; | ||
|
||
@Controller('avatar-upload') | ||
@UseGuards(AccessTokenGuard) | ||
export class AvatarUploadController { | ||
constructor(private readonly avatarUploadService: AvatarUploadService) {} | ||
|
||
@Post() | ||
@UseInterceptors(FileInterceptor('file')) | ||
create( | ||
@UploadedFile( | ||
new ParseFilePipe({ | ||
validators: fileValidators, | ||
}), | ||
) | ||
file: Express.Multer.File, | ||
@Req() request: Request & { user: User }, | ||
) { | ||
const { id } = request.user; | ||
|
||
return this.avatarUploadService.create(id, file); | ||
} | ||
|
||
@Patch() | ||
update( | ||
@UploadedFile( | ||
new ParseFilePipe({ | ||
validators: fileValidators, | ||
}), | ||
) | ||
file: Express.Multer.File, | ||
@Req() request: Request & { user: User }, | ||
) { | ||
const { id } = request.user; | ||
|
||
return this.avatarUploadService.update(id, file); | ||
} | ||
|
||
@Delete() | ||
remove(@Req() request: Request & { user: User }) { | ||
const { id } = request.user; | ||
|
||
return this.avatarUploadService.remove(id); | ||
} | ||
} |
Oops, something went wrong.