From 14a05446e4a8a1f4e69bc8e6268ec1b9210a9e79 Mon Sep 17 00:00:00 2001 From: Carlo M Date: Mon, 21 Oct 2024 06:51:05 -0600 Subject: [PATCH 1/7] Tweaked CICD, removed husky, removed fly deployment --- .dockerignore | 4 ---- .github/workflows/ci.yml | 5 ----- .github/workflows/deploy.yml | 21 ------------------ .husky/pre-commit | 4 ---- DB_SETUP.md | 18 ---------------- Dockerfile | 36 ------------------------------- fly.toml | 42 ------------------------------------ package.json | 2 -- 8 files changed, 132 deletions(-) delete mode 100644 .dockerignore delete mode 100644 .github/workflows/deploy.yml delete mode 100644 .husky/pre-commit delete mode 100644 DB_SETUP.md delete mode 100644 Dockerfile delete mode 100644 fly.toml diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 79297ed5..00000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -Dockerfile -.dockerignore -node_modules -.git diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56cddc0a..1e2ff854 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,5 @@ name: CI on: [push, pull_request] -env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} - JWT_TOKEN: ${{ secrets.JWT_TOKEN }} - JWT_EXPIRY: ${{ secrets.JWT_EXPIRY }} jobs: test: runs-on: ubuntu-latest @@ -14,4 +10,3 @@ jobs: node-version: 'lts/*' - run: npm ci - run: npx eslint src - - run: npx prisma migrate reset --force --skip-seed diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 471052aa..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Fly Deploy -on: - push: - branches: - - main -env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - DATABASE_URL: ${{ secrets.DATABASE_URL }} - JWT_SECRET: ${{ secrets.JWT_SECRET }} - JWT_EXPIRY: ${{ secrets.JWT_EXPIRY }} -jobs: - deploy: - name: Deploy app to fly.io - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: superfly/flyctl-actions/setup-flyctl@master - - run: echo DATABASE_URL=$DATABASE_URL >> .env - - run: echo JWT_SECRET=$JWT_SECRET >> .env - - run: echo JWT_EXPIRY=$JWT_EXPIRY >> .env - - run: flyctl deploy --remote-only diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index a41979b3..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx eslint src \ No newline at end of file diff --git a/DB_SETUP.md b/DB_SETUP.md deleted file mode 100644 index 5a966b81..00000000 --- a/DB_SETUP.md +++ /dev/null @@ -1,18 +0,0 @@ -## Creating your databases with ElephantSQL - -1. [Sign in to ElephantSQL](https://customer.elephantsql.com/login) using your GitHub account - - If it asks you to create a team, create one with any name - -2. When logged in, click the green *Create New Instance* button in the top right -![](./assets/db-setup/1.PNG) - -3. Enter a name for your new database instance and choose the *Tiny Turtle (Free)* plan. **This will be your PRIMARY database** -![](./assets/db-setup/2.PNG) - -4. Repeat the same steps to create a second database, this time give it the same name but add `-shadow` to the end. **This will be your SHADOW database** - -5. In your shadow instance: - - click the *Browser* menu item on the left side of the screen - - in the SQL Browser text input, enter `CREATE SCHEMA shadow;` - - click the *Execute* button -![](./assets/db-setup/3.PNG) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index b0c8ba77..00000000 --- a/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -FROM debian:bullseye as builder - -ARG NODE_VERSION=18.12.1 - -RUN apt-get update; apt install -y curl -RUN curl https://get.volta.sh | bash -ENV VOLTA_HOME /root/.volta -ENV PATH /root/.volta/bin:$PATH -RUN volta install node@${NODE_VERSION} - -####################################################################### - -RUN mkdir /app -WORKDIR /app - -# NPM will not install any package listed in "devDependencies" when NODE_ENV is set to "production", -# to install all modules: "npm install --production=false". -# Ref: https://docs.npmjs.com/cli/v9/commands/npm-install#description - -ENV NODE_ENV production - -COPY . . - -RUN npm install -FROM debian:bullseye - -LABEL fly_launch_runtime="nodejs" - -COPY --from=builder /root/.volta /root/.volta -COPY --from=builder /app /app - -WORKDIR /app -ENV NODE_ENV production -ENV PATH /root/.volta/bin:$PATH - -CMD [ "npm", "run", "start" ] diff --git a/fly.toml b/fly.toml deleted file mode 100644 index eac058e7..00000000 --- a/fly.toml +++ /dev/null @@ -1,42 +0,0 @@ -# fly.toml file generated for team-dev-backend-api on 2022-11-30T11:30:34Z - -app = "team-dev-backend-api" -kill_signal = "SIGINT" -kill_timeout = 5 -processes = [] - -[env] - PORT = "8080" - -[experimental] - allowed_public_ports = [] - auto_rollback = true - -[deploy] - release_command = "npx prisma migrate deploy" - -[[services]] - http_checks = [] - internal_port = 8080 - processes = ["app"] - protocol = "tcp" - script_checks = [] - [services.concurrency] - hard_limit = 25 - soft_limit = 20 - type = "connections" - - [[services.ports]] - force_https = true - handlers = ["http"] - port = 80 - - [[services.ports]] - handlers = ["tls", "http"] - port = 443 - - [[services.tcp_checks]] - grace_period = "1s" - interval = "15s" - restart_limit = 0 - timeout = "2s" diff --git a/package.json b/package.json index 41e19e5e..4efc3e40 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "scripts": { "start": "node src/index.js", "dev": "nodemon src/index.js", - "prepare": "husky install", "db-reset": "prisma migrate reset" }, "prisma": { @@ -33,7 +32,6 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-promise": "^5.1.0", - "husky": "^7.0.4", "nodemon": "^2.0.15", "prettier": "^2.6.2", "prisma": "^3.12.0" From 3d2add59c7c4f3cda3dd117afcbcd92321b9df91 Mon Sep 17 00:00:00 2001 From: Oliver Andersson Date: Mon, 28 Oct 2024 22:45:02 +0100 Subject: [PATCH 2/7] First untested version of an implementation for comments on posts. --- prisma/schema.prisma | 12 ++++++++++++ src/controllers/comment.js | 33 +++++++++++++++++++++++++++++++++ src/domain/comment.js | 28 ++++++++++++++++++++++++++++ src/routes/comment.js | 10 ++++++++++ src/server.js | 2 ++ 5 files changed, 85 insertions(+) create mode 100644 src/controllers/comment.js create mode 100644 src/domain/comment.js create mode 100644 src/routes/comment.js diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 72ec5632..e205720d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -25,6 +25,7 @@ model User { cohortId Int? cohort Cohort? @relation(fields: [cohortId], references: [id]) posts Post[] + comments Comment[] deliveryLogs DeliveryLog[] } @@ -49,6 +50,17 @@ model Post { content String userId Int user User @relation(fields: [userId], references: [id]) + comments Comment[] +} + +model Comment { + id Int @id @default(autoincrement()) + content String + userId Int + user User @relation(fields: [userId], references: [id]) + postId Int + post Post @relation(fields: [postId], references: [id]) + createdAt DateTime @default(now()) } model DeliveryLog { diff --git a/src/controllers/comment.js b/src/controllers/comment.js new file mode 100644 index 00000000..29b0adbf --- /dev/null +++ b/src/controllers/comment.js @@ -0,0 +1,33 @@ +import { sendDataResponse, sendMessageResponse } from '../utils/responses.js'; +import Comment from '../domain/comment.js'; + +export const createComment = async (req, res) => { + const { postId, content } = req.body; + + if (!postId || !content) { + return sendDataResponse(res, 400, { message: 'Post ID and content are required' }); + } + + try { + const comment = await Comment.create({ + postId: parseInt(postId), + userId: req.user.id, + content, + }); + + return sendDataResponse(res, 201, { comment }); + } catch (error) { + return sendMessageResponse(res, 500, 'Unable to create comment'); + } +}; + +export const getCommentsByPost = async (req, res) => { + const { postId } = req.params; + + try { + const comments = await Comment.findByPostId(parseInt(postId)); + return sendDataResponse(res, 200, { comments }); + } catch (error) { + return sendMessageResponse(res, 500, 'Unable to retrieve comments'); + } +}; diff --git a/src/domain/comment.js b/src/domain/comment.js new file mode 100644 index 00000000..203f7a28 --- /dev/null +++ b/src/domain/comment.js @@ -0,0 +1,28 @@ +import dbClient from '../utils/dbClient.js'; + +export default class Comment { + static async create({ postId, userId, content }) { + const newComment = await dbClient.comment.create({ + data: { + postId, + userId, + content, + }, + include: { + user: { select: { id: true, email: true } }, + post: { select: { id: true } }, + }, + }); + return newComment; + } + + static async findByPostId(postId) { + return dbClient.comment.findMany({ + where: { postId }, + include: { + user: { select: { id: true, email: true, profile: true } }, + }, + orderBy: { createdAt: 'asc' }, + }); + } +} diff --git a/src/routes/comment.js b/src/routes/comment.js new file mode 100644 index 00000000..62eca8e6 --- /dev/null +++ b/src/routes/comment.js @@ -0,0 +1,10 @@ +import { Router } from 'express'; +import { createComment, getCommentsByPost } from '../controllers/comment.js'; +import { validateAuthentication } from '../middleware/auth.js'; + +const router = Router(); + +router.post('/', validateAuthentication, createComment); +router.get('/post/:postId', validateAuthentication, getCommentsByPost); + +export default router; diff --git a/src/server.js b/src/server.js index a3f67eeb..3573e461 100644 --- a/src/server.js +++ b/src/server.js @@ -7,6 +7,7 @@ import cors from 'cors' import userRouter from './routes/user.js' import postRouter from './routes/post.js' import authRouter from './routes/auth.js' +import commentRouter from './routes/comment.js' import cohortRouter from './routes/cohort.js' import deliveryLogRouter from './routes/deliveryLog.js' @@ -25,6 +26,7 @@ app.use('/users', userRouter) app.use('/posts', postRouter) app.use('/cohorts', cohortRouter) app.use('/logs', deliveryLogRouter) +app.use('/comments', commentRouter) app.use('/', authRouter) app.get('*', (req, res) => { From 538827752a49a9ae6d6315672738cd76ad7ded94 Mon Sep 17 00:00:00 2001 From: Iris Flystam Date: Tue, 29 Oct 2024 08:12:42 +0100 Subject: [PATCH 3/7] updated prisma to work in accordance to the api spec --- .env.example | 5 ---- package-lock.json | 28 +++---------------- package.json | 4 +-- .../migration.sql | 16 +++++++++++ prisma/schema.prisma | 12 +++++--- 5 files changed, 30 insertions(+), 35 deletions(-) delete mode 100644 .env.example create mode 100644 prisma/migrations/20241029071000_prisma_update_24_10_29_08_03_iris_flystam/migration.sql diff --git a/.env.example b/.env.example deleted file mode 100644 index 932b9f1e..00000000 --- a/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -PORT=4000 -DATABASE_URL="?schema=prisma" -SHADOW_DATABASE_URL="?schema=shadow" -JWT_SECRET="somesecurestring" -JWT_EXPIRY="24h" \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 044145e5..7e1b2897 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@prisma/client": "^3.12.0", + "@prisma/client": "^3.15.2", "bcrypt": "^5.0.1", "cors": "^2.8.5", "dotenv": "^16.0.0", @@ -27,10 +27,9 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-promise": "^5.1.0", - "husky": "^7.0.4", "nodemon": "^2.0.15", "prettier": "^2.6.2", - "prisma": "^3.12.0" + "prisma": "^3.15.2" } }, "node_modules/@babel/code-frame": { @@ -206,6 +205,7 @@ "resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.15.2.tgz", "integrity": "sha512-ErqtwhX12ubPhU4d++30uFY/rPcyvjk+mdifaZO5SeM21zS3t4jQrscy8+6IyB0GIYshl5ldTq6JSBo1d63i8w==", "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { "@prisma/engines-version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e" }, @@ -1765,21 +1765,6 @@ "node": ">= 6" } }, - "node_modules/husky": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", - "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", - "dev": true, - "bin": { - "husky": "lib/bin.js" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -2770,6 +2755,7 @@ "integrity": "sha512-nMNSMZvtwrvoEQ/mui8L/aiCLZRCj5t6L3yujKpcDhIPk7garp8tL4nMx2+oYsN0FWBacevJhazfXAbV1kfBzA==", "devOptional": true, "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { "@prisma/engines": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e" }, @@ -4893,12 +4879,6 @@ "debug": "4" } }, - "husky": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", - "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", - "dev": true - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", diff --git a/package.json b/package.json index 3021b44f..ae8a6d92 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,10 @@ "eslint-plugin-promise": "^5.1.0", "nodemon": "^2.0.15", "prettier": "^2.6.2", - "prisma": "^3.12.0" + "prisma": "^3.15.2" }, "dependencies": { - "@prisma/client": "^3.12.0", + "@prisma/client": "^3.15.2", "bcrypt": "^5.0.1", "cors": "^2.8.5", "dotenv": "^16.0.0", diff --git a/prisma/migrations/20241029071000_prisma_update_24_10_29_08_03_iris_flystam/migration.sql b/prisma/migrations/20241029071000_prisma_update_24_10_29_08_03_iris_flystam/migration.sql new file mode 100644 index 00000000..61ef7be7 --- /dev/null +++ b/prisma/migrations/20241029071000_prisma_update_24_10_29_08_03_iris_flystam/migration.sql @@ -0,0 +1,16 @@ +/* + Warnings: + + - Added the required column `createdAt` to the `Cohort` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `Cohort` table without a default value. This is not possible if the table is not empty. + - Added the required column `createdAt` to the `Post` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `Post` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Cohort" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL, +ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL; + +-- AlterTable +ALTER TABLE "Post" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL, +ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 72ec5632..a8b756d8 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -41,14 +41,18 @@ model Profile { model Cohort { id Int @id @default(autoincrement()) users User[] + createdAt DateTime + updatedAt DateTime deliveryLogs DeliveryLog[] } model Post { - id Int @id @default(autoincrement()) - content String - userId Int - user User @relation(fields: [userId], references: [id]) + id Int @id @default(autoincrement()) + content String + createdAt DateTime + updatedAt DateTime + userId Int + user User @relation(fields: [userId], references: [id]) } model DeliveryLog { From b63509c80f3fad1c58f338b068706bd575faab3d Mon Sep 17 00:00:00 2001 From: Oliver Andersson Date: Tue, 29 Oct 2024 09:23:29 +0100 Subject: [PATCH 4/7] Removal of ";" i multiple files --- src/controllers/comment.js | 24 ++++++++++++------------ src/domain/comment.js | 8 ++++---- src/routes/comment.js | 14 +++++++------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/controllers/comment.js b/src/controllers/comment.js index 29b0adbf..6109c1d7 100644 --- a/src/controllers/comment.js +++ b/src/controllers/comment.js @@ -1,11 +1,11 @@ -import { sendDataResponse, sendMessageResponse } from '../utils/responses.js'; -import Comment from '../domain/comment.js'; +import { sendDataResponse, sendMessageResponse } from '../utils/responses.js' +import Comment from '../domain/comment.js' export const createComment = async (req, res) => { - const { postId, content } = req.body; + const { postId, content } = req.body if (!postId || !content) { - return sendDataResponse(res, 400, { message: 'Post ID and content are required' }); + return sendDataResponse(res, 400, { message: 'Post ID and content are required' }) } try { @@ -13,21 +13,21 @@ export const createComment = async (req, res) => { postId: parseInt(postId), userId: req.user.id, content, - }); + }) return sendDataResponse(res, 201, { comment }); } catch (error) { - return sendMessageResponse(res, 500, 'Unable to create comment'); + return sendMessageResponse(res, 500, 'Unable to create comment') } -}; +} export const getCommentsByPost = async (req, res) => { - const { postId } = req.params; + const { postId } = req.params try { - const comments = await Comment.findByPostId(parseInt(postId)); - return sendDataResponse(res, 200, { comments }); + const comments = await Comment.findByPostId(parseInt(postId)) + return sendDataResponse(res, 200, { comments }) } catch (error) { - return sendMessageResponse(res, 500, 'Unable to retrieve comments'); + return sendMessageResponse(res, 500, 'Unable to retrieve comments') } -}; +} diff --git a/src/domain/comment.js b/src/domain/comment.js index 203f7a28..5e3d4098 100644 --- a/src/domain/comment.js +++ b/src/domain/comment.js @@ -1,4 +1,4 @@ -import dbClient from '../utils/dbClient.js'; +import dbClient from '../utils/dbClient.js' export default class Comment { static async create({ postId, userId, content }) { @@ -12,8 +12,8 @@ export default class Comment { user: { select: { id: true, email: true } }, post: { select: { id: true } }, }, - }); - return newComment; + }) + return newComment } static async findByPostId(postId) { @@ -23,6 +23,6 @@ export default class Comment { user: { select: { id: true, email: true, profile: true } }, }, orderBy: { createdAt: 'asc' }, - }); + }) } } diff --git a/src/routes/comment.js b/src/routes/comment.js index 62eca8e6..fe4b31c0 100644 --- a/src/routes/comment.js +++ b/src/routes/comment.js @@ -1,10 +1,10 @@ -import { Router } from 'express'; -import { createComment, getCommentsByPost } from '../controllers/comment.js'; -import { validateAuthentication } from '../middleware/auth.js'; +import { Router } from 'express' +import { createComment, getCommentsByPost } from '../controllers/comment.js' +import { validateAuthentication } from '../middleware/auth.js' -const router = Router(); +const router = Router() -router.post('/', validateAuthentication, createComment); -router.get('/post/:postId', validateAuthentication, getCommentsByPost); +router.post('/', validateAuthentication, createComment) +router.get('/post/:postId', validateAuthentication, getCommentsByPost) -export default router; +export default router From 9c337319b65c10f07a8ee4f0829aaa19fd65036c Mon Sep 17 00:00:00 2001 From: Oliver Andersson Date: Tue, 29 Oct 2024 09:28:56 +0100 Subject: [PATCH 5/7] Removal of "," i multiple files and adjustments to match prettier --- src/controllers/comment.js | 8 +++++--- src/domain/comment.js | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/controllers/comment.js b/src/controllers/comment.js index 6109c1d7..d2d678a9 100644 --- a/src/controllers/comment.js +++ b/src/controllers/comment.js @@ -5,17 +5,19 @@ export const createComment = async (req, res) => { const { postId, content } = req.body if (!postId || !content) { - return sendDataResponse(res, 400, { message: 'Post ID and content are required' }) + return sendDataResponse(res, 400, { + message: 'Post ID and content are required' + }) } try { const comment = await Comment.create({ postId: parseInt(postId), userId: req.user.id, - content, + content }) - return sendDataResponse(res, 201, { comment }); + return sendDataResponse(res, 201, { comment }) } catch (error) { return sendMessageResponse(res, 500, 'Unable to create comment') } diff --git a/src/domain/comment.js b/src/domain/comment.js index 5e3d4098..da47d1d0 100644 --- a/src/domain/comment.js +++ b/src/domain/comment.js @@ -6,12 +6,12 @@ export default class Comment { data: { postId, userId, - content, + content }, include: { user: { select: { id: true, email: true } }, - post: { select: { id: true } }, - }, + post: { select: { id: true } } + } }) return newComment } @@ -20,9 +20,9 @@ export default class Comment { return dbClient.comment.findMany({ where: { postId }, include: { - user: { select: { id: true, email: true, profile: true } }, + user: { select: { id: true, email: true, profile: true } } }, - orderBy: { createdAt: 'asc' }, + orderBy: { createdAt: 'asc' } }) } } From 8498242f59d41cbbcb65a0afbf71e9fee355807e Mon Sep 17 00:00:00 2001 From: Oliver Andersson Date: Tue, 29 Oct 2024 10:37:24 +0100 Subject: [PATCH 6/7] Added migration for comments --- .../migration.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 prisma/migrations/20241028210717_add_comments_to_posts/migration.sql diff --git a/prisma/migrations/20241028210717_add_comments_to_posts/migration.sql b/prisma/migrations/20241028210717_add_comments_to_posts/migration.sql new file mode 100644 index 00000000..0651634d --- /dev/null +++ b/prisma/migrations/20241028210717_add_comments_to_posts/migration.sql @@ -0,0 +1,16 @@ +-- CreateTable +CREATE TABLE "Comment" ( + "id" SERIAL NOT NULL, + "content" TEXT NOT NULL, + "userId" INTEGER NOT NULL, + "postId" INTEGER NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Comment_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE RESTRICT ON UPDATE CASCADE; From 4ed88fa1b626eff87ed6da3bade0a6b9978ac2dd Mon Sep 17 00:00:00 2001 From: Iris Flystam Date: Tue, 29 Oct 2024 13:48:44 +0100 Subject: [PATCH 7/7] tried to fix merge comments --- env.example | 5 +++++ package-lock.json | 28 ++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 env.example diff --git a/env.example b/env.example new file mode 100644 index 00000000..932b9f1e --- /dev/null +++ b/env.example @@ -0,0 +1,5 @@ +PORT=4000 +DATABASE_URL="?schema=prisma" +SHADOW_DATABASE_URL="?schema=shadow" +JWT_SECRET="somesecurestring" +JWT_EXPIRY="24h" \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7e1b2897..044145e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@prisma/client": "^3.15.2", + "@prisma/client": "^3.12.0", "bcrypt": "^5.0.1", "cors": "^2.8.5", "dotenv": "^16.0.0", @@ -27,9 +27,10 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-promise": "^5.1.0", + "husky": "^7.0.4", "nodemon": "^2.0.15", "prettier": "^2.6.2", - "prisma": "^3.15.2" + "prisma": "^3.12.0" } }, "node_modules/@babel/code-frame": { @@ -205,7 +206,6 @@ "resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.15.2.tgz", "integrity": "sha512-ErqtwhX12ubPhU4d++30uFY/rPcyvjk+mdifaZO5SeM21zS3t4jQrscy8+6IyB0GIYshl5ldTq6JSBo1d63i8w==", "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { "@prisma/engines-version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e" }, @@ -1765,6 +1765,21 @@ "node": ">= 6" } }, + "node_modules/husky": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", + "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -2755,7 +2770,6 @@ "integrity": "sha512-nMNSMZvtwrvoEQ/mui8L/aiCLZRCj5t6L3yujKpcDhIPk7garp8tL4nMx2+oYsN0FWBacevJhazfXAbV1kfBzA==", "devOptional": true, "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { "@prisma/engines": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e" }, @@ -4879,6 +4893,12 @@ "debug": "4" } }, + "husky": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", + "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", + "dev": true + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",