From 19554d0f1027f6e4c14ae50b06d6ee8ad963fdd3 Mon Sep 17 00:00:00 2001 From: yungblud Date: Sun, 14 Jan 2024 23:40:14 +0900 Subject: [PATCH] feat: migrated store server --- packages/store-server/.env.example | 7 ++ packages/store-server/.eslintrc | 9 ++ packages/store-server/.gitignore | 11 ++ packages/store-server/.prettierrc.json | 6 + packages/store-server/Dockerfile.example | 14 +++ .../store-server/docker-compose.example.yml | 16 +++ packages/store-server/package.json | 29 +++++ .../20231213115753_init/migration.sql | 29 +++++ .../prisma/migrations/migration_lock.toml | 3 + packages/store-server/prisma/schema.prisma | 28 +++++ .../src/api/controllers/authController.ts | 64 ++++++++++ .../src/api/controllers/meController.ts | 14 +++ .../src/api/controllers/userController.ts | 10 ++ .../store-server/src/api/database/prisma.ts | 3 + .../store-server/src/api/models/AuthToken.ts | 77 +++++++++++++ packages/store-server/src/api/models/User.ts | 49 ++++++++ packages/store-server/src/api/routes/auth.ts | 9 ++ packages/store-server/src/api/routes/me.ts | 9 ++ packages/store-server/src/api/routes/user.ts | 9 ++ .../src/config/config.example.json | 6 + .../src/config/ecosystem.config.js | 8 ++ packages/store-server/src/server.ts | 57 +++++++++ packages/store-server/src/types/auth.ts | 1 + .../store-server/src/types/fastify-jwt.d.ts | 14 +++ packages/store-server/src/types/jwt.ts | 15 +++ packages/store-server/tsconfig.json | 109 ++++++++++++++++++ packages/wamuseum-server/package.json | 2 +- yarn.lock | 27 +++-- 28 files changed, 627 insertions(+), 8 deletions(-) create mode 100644 packages/store-server/.env.example create mode 100644 packages/store-server/.eslintrc create mode 100644 packages/store-server/.gitignore create mode 100644 packages/store-server/.prettierrc.json create mode 100644 packages/store-server/Dockerfile.example create mode 100644 packages/store-server/docker-compose.example.yml create mode 100644 packages/store-server/package.json create mode 100644 packages/store-server/prisma/migrations/20231213115753_init/migration.sql create mode 100644 packages/store-server/prisma/migrations/migration_lock.toml create mode 100644 packages/store-server/prisma/schema.prisma create mode 100644 packages/store-server/src/api/controllers/authController.ts create mode 100644 packages/store-server/src/api/controllers/meController.ts create mode 100644 packages/store-server/src/api/controllers/userController.ts create mode 100644 packages/store-server/src/api/database/prisma.ts create mode 100644 packages/store-server/src/api/models/AuthToken.ts create mode 100644 packages/store-server/src/api/models/User.ts create mode 100644 packages/store-server/src/api/routes/auth.ts create mode 100644 packages/store-server/src/api/routes/me.ts create mode 100644 packages/store-server/src/api/routes/user.ts create mode 100644 packages/store-server/src/config/config.example.json create mode 100644 packages/store-server/src/config/ecosystem.config.js create mode 100644 packages/store-server/src/server.ts create mode 100644 packages/store-server/src/types/auth.ts create mode 100644 packages/store-server/src/types/fastify-jwt.d.ts create mode 100644 packages/store-server/src/types/jwt.ts create mode 100644 packages/store-server/tsconfig.json diff --git a/packages/store-server/.env.example b/packages/store-server/.env.example new file mode 100644 index 0000000..1acd3b2 --- /dev/null +++ b/packages/store-server/.env.example @@ -0,0 +1,7 @@ +# Environment variables declared in this file are automatically made available to Prisma. +# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema + +# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. +# See the documentation for all the connection string options: https://pris.ly/d/connection-strings + +DATABASE_URL="" \ No newline at end of file diff --git a/packages/store-server/.eslintrc b/packages/store-server/.eslintrc new file mode 100644 index 0000000..752bb5f --- /dev/null +++ b/packages/store-server/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": [ + "coldsurfers", // for nodejs-typescript, or 'coldsurfers/nodejs-typescript' + "coldsurfers/react-typescript" // for react-typescript + ], + "rules": { + "camelcase": "off" + } +} \ No newline at end of file diff --git a/packages/store-server/.gitignore b/packages/store-server/.gitignore new file mode 100644 index 0000000..52e66d1 --- /dev/null +++ b/packages/store-server/.gitignore @@ -0,0 +1,11 @@ +node_modules +# Keep environment variables out of version control +.env + +src/config/config.json + +Dockerfile + +dist/ + +docker-compose.yml \ No newline at end of file diff --git a/packages/store-server/.prettierrc.json b/packages/store-server/.prettierrc.json new file mode 100644 index 0000000..fbe0e55 --- /dev/null +++ b/packages/store-server/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 2, + "semi": false, + "singleQuote": true +} \ No newline at end of file diff --git a/packages/store-server/Dockerfile.example b/packages/store-server/Dockerfile.example new file mode 100644 index 0000000..823bc76 --- /dev/null +++ b/packages/store-server/Dockerfile.example @@ -0,0 +1,14 @@ +# https://umanking.github.io/2023/08/04/mysql-dockerfile/ +# Dockerfile + +# MySQL 이미지를 기반으로 이미지 생성 +FROM mysql:latest + +# MySQL 설정 +ENV MYSQL_ROOT_PASSWORD=my-secret-pw +ENV MYSQL_DATABASE=mydb +ENV MYSQL_USER=myuser +ENV MYSQL_PASSWORD=mypassword + +# 포트 설정 (기본 MySQL 포트는 3306) +EXPOSE 3306 \ No newline at end of file diff --git a/packages/store-server/docker-compose.example.yml b/packages/store-server/docker-compose.example.yml new file mode 100644 index 0000000..d9ce0c6 --- /dev/null +++ b/packages/store-server/docker-compose.example.yml @@ -0,0 +1,16 @@ +# https://wecandev.tistory.com/107 + +version: '3' +services: + mysql: + image: mysql:8.0 + container_name: mysql + ports: + - 3306:3306 # HOST:CONTAINER + environment: + MYSQL_ROOT_PASSWORD: admin + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + volumes: + - D:/mysql/data:/var/lib/mysql \ No newline at end of file diff --git a/packages/store-server/package.json b/packages/store-server/package.json new file mode 100644 index 0000000..e052102 --- /dev/null +++ b/packages/store-server/package.json @@ -0,0 +1,29 @@ +{ + "name": "server", + "version": "1.0.0", + "license": "MIT", + "scripts": { + "dev": "NODE_ENV=development npx ts-node ./src/server.ts", + "start": "NODE_ENV=production node ./dist/server.js", + "build": "tsc && cp -R ./src/config ./dist/config", + "deploy": "yarn pm2 start ./src/config/ecosystem.config.js" + }, + "devDependencies": { + "@types/nconf": "^0.10.6", + "@types/node": "^20", + "pm2": "^5.3.0", + "prisma": "^5.7.1", + "typescript": "^5" + }, + "dependencies": { + "@fastify/autoload": "^5.8.0", + "@fastify/cors": "^8.4.2", + "@fastify/jwt": "^7.2.4", + "@prisma/client": "^5.7.1", + "fastify": "^4.24.3", + "google-auth-library": "^9.4.1", + "nconf": "^0.12.1", + "uuidv4": "^6.2.13", + "zod": "^3.22.4" + } +} diff --git a/packages/store-server/prisma/migrations/20231213115753_init/migration.sql b/packages/store-server/prisma/migrations/20231213115753_init/migration.sql new file mode 100644 index 0000000..7672ec1 --- /dev/null +++ b/packages/store-server/prisma/migrations/20231213115753_init/migration.sql @@ -0,0 +1,29 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL, + "email" TEXT NOT NULL, + "password" VARCHAR(255), + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "AuthToken" ( + "id" TEXT NOT NULL, + "auth_token" TEXT NOT NULL, + "refresh_token" TEXT NOT NULL, + "user_id" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "AuthToken_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "AuthToken_user_id_key" ON "AuthToken"("user_id"); + +-- AddForeignKey +ALTER TABLE "AuthToken" ADD CONSTRAINT "AuthToken_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/packages/store-server/prisma/migrations/migration_lock.toml b/packages/store-server/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..fbffa92 --- /dev/null +++ b/packages/store-server/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "postgresql" \ No newline at end of file diff --git a/packages/store-server/prisma/schema.prisma b/packages/store-server/prisma/schema.prisma new file mode 100644 index 0000000..2b62cdd --- /dev/null +++ b/packages/store-server/prisma/schema.prisma @@ -0,0 +1,28 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model User { + id String @id @default(uuid()) + email String @unique + password String? @db.VarChar(255) + created_at DateTime @default(now()) + auth_token AuthToken? +} + +model AuthToken { + id String @id @default(uuid()) + auth_token String @db.Text + refresh_token String @db.Text + user User @relation(fields: [user_id], references: [id]) + user_id String @unique + created_at DateTime @default(now()) +} diff --git a/packages/store-server/src/api/controllers/authController.ts b/packages/store-server/src/api/controllers/authController.ts new file mode 100644 index 0000000..9fa4298 --- /dev/null +++ b/packages/store-server/src/api/controllers/authController.ts @@ -0,0 +1,64 @@ +import { RouteHandler } from 'fastify' +import { OAuth2Client } from 'google-auth-library' +import User from '../models/User' +import AuthToken from '../models/AuthToken' + +const client = new OAuth2Client() + +export const socialSignInCtrl: RouteHandler<{ + Body: { + social_token: string + provider: 'google' + } +}> = async (req, res) => { + const { social_token: socialToken, provider } = req.body + try { + if (provider === 'google') { + const tokenInfo = await client.getTokenInfo(socialToken) + const { email: gmail } = tokenInfo + if (!gmail) { + throw Error('cannot get gmail') + } + let user = await User.findByEmail(gmail) + if (!user) { + user = await new User({ + email: gmail, + }).create() + } + const authToken = new AuthToken({ + auth_token: await res.jwtSign( + { + provider, + email: user.email, + id: user.id, + }, + { + expiresIn: '7d', + } + ), + refresh_token: await res.jwtSign( + { + provider, + email: user.email, + id: user.id, + }, + { + expiresIn: '30d', + } + ), + user_id: user.id, + }) + const { refresh_token, auth_token } = await authToken.create() + + return res.status(200).send({ + refresh_token, + auth_token, + user, + }) + } + return res.status(404).send() + } catch (e) { + console.error(e) + return res.send(e) + } +} diff --git a/packages/store-server/src/api/controllers/meController.ts b/packages/store-server/src/api/controllers/meController.ts new file mode 100644 index 0000000..4b75051 --- /dev/null +++ b/packages/store-server/src/api/controllers/meController.ts @@ -0,0 +1,14 @@ +import { FastifyError, RouteHandler } from 'fastify' +// import { JWTDecoded } from '../../types/jwt' + +export const getMeCtrl: RouteHandler<{}> = async (req, rep) => { + try { + await req.jwtVerify() + // const decoded = (await req.jwtDecode()) as JWTDecoded + // todo find user by auth token + return rep.status(501) + } catch (e) { + const error = e as FastifyError + return rep.status(error.statusCode ?? 500).send(error) + } +} diff --git a/packages/store-server/src/api/controllers/userController.ts b/packages/store-server/src/api/controllers/userController.ts new file mode 100644 index 0000000..5ded820 --- /dev/null +++ b/packages/store-server/src/api/controllers/userController.ts @@ -0,0 +1,10 @@ +import { RouteHandler } from 'fastify' + +export const getUserCtrl: RouteHandler<{ + Params: { + userId: string + } +}> = (req, res) => + res.status(200).send({ + status: 'okay', + }) diff --git a/packages/store-server/src/api/database/prisma.ts b/packages/store-server/src/api/database/prisma.ts new file mode 100644 index 0000000..6260dd0 --- /dev/null +++ b/packages/store-server/src/api/database/prisma.ts @@ -0,0 +1,3 @@ +import { PrismaClient } from '@prisma/client' + +export const prisma = new PrismaClient() diff --git a/packages/store-server/src/api/models/AuthToken.ts b/packages/store-server/src/api/models/AuthToken.ts new file mode 100644 index 0000000..164b548 --- /dev/null +++ b/packages/store-server/src/api/models/AuthToken.ts @@ -0,0 +1,77 @@ +import { prisma } from '../database/prisma' + +export type AuthTokenSerialized = { + id: string + auth_token: string + refresh_token: string + user_id: string + created_at: string +} + +export default class AuthToken { + public id?: string + + public auth_token!: string + + public refresh_token!: string + + public user_id!: string + + public created_at?: Date + + constructor(params: { + id?: string + auth_token: string + refresh_token: string + user_id: string + created_at?: Date + }) { + this.id = params.id + this.auth_token = params.auth_token + this.refresh_token = params.refresh_token + this.user_id = params.user_id + this.created_at = params.created_at + } + + public static async getByUserId(userId: string) { + // eslint-disable-next-line no-return-await + return await prisma.authToken.findUnique({ + where: { + user_id: userId, + }, + }) + } + + public static async deleteById(id: string) { + await prisma.authToken.delete({ + where: { + id, + }, + }) + } + + public async create() { + const existing = await AuthToken.getByUserId(this.user_id) + if (existing) { + await AuthToken.deleteById(existing.id) + } + // eslint-disable-next-line no-return-await + return await prisma.authToken.create({ + data: { + auth_token: this.auth_token, + refresh_token: this.refresh_token, + user_id: this.user_id, + }, + }) + } + + public serialize(): AuthTokenSerialized { + return { + id: this.id ?? '', + auth_token: this.auth_token, + refresh_token: this.refresh_token, + user_id: this.user_id, + created_at: this.created_at?.toISOString() ?? '', + } + } +} diff --git a/packages/store-server/src/api/models/User.ts b/packages/store-server/src/api/models/User.ts new file mode 100644 index 0000000..4e834bd --- /dev/null +++ b/packages/store-server/src/api/models/User.ts @@ -0,0 +1,49 @@ +/* eslint-disable class-methods-use-this */ +import { prisma } from '../database/prisma' + +export type UserSerialized = { + id: string + email: string + created_at: string +} + +export default class User { + public id?: string + + public email!: string + + public created_at?: Date + + constructor(params: { id?: string; email: string; created_at?: Date }) { + this.id = params.id + this.email = params.email + this.created_at = params.created_at + } + + public static async findByEmail(email: string) { + const user = await prisma.user.findUnique({ + where: { + email, + }, + }) + + return user + } + + public async create() { + const user = await prisma.user.create({ + data: { + email: this.email, + }, + }) + return user + } + + public serialize(): UserSerialized { + return { + id: this.id ?? '', + email: this.email, + created_at: this.created_at?.toISOString() ?? '', + } + } +} diff --git a/packages/store-server/src/api/routes/auth.ts b/packages/store-server/src/api/routes/auth.ts new file mode 100644 index 0000000..f5ce7df --- /dev/null +++ b/packages/store-server/src/api/routes/auth.ts @@ -0,0 +1,9 @@ +import { FastifyPluginCallback } from 'fastify' +import { socialSignInCtrl } from '../controllers/authController' + +const authRoute: FastifyPluginCallback = (fastify, opts, done) => { + fastify.post('/auth/social-signin', socialSignInCtrl) + done() +} + +export default authRoute diff --git a/packages/store-server/src/api/routes/me.ts b/packages/store-server/src/api/routes/me.ts new file mode 100644 index 0000000..112efa2 --- /dev/null +++ b/packages/store-server/src/api/routes/me.ts @@ -0,0 +1,9 @@ +import { FastifyPluginCallback } from 'fastify' +import { getMeCtrl } from '../controllers/meController' + +const meRoute: FastifyPluginCallback = (fastify, opts, done) => { + fastify.get('/me', getMeCtrl) + done() +} + +export default meRoute diff --git a/packages/store-server/src/api/routes/user.ts b/packages/store-server/src/api/routes/user.ts new file mode 100644 index 0000000..343f1ce --- /dev/null +++ b/packages/store-server/src/api/routes/user.ts @@ -0,0 +1,9 @@ +import { FastifyPluginCallback } from 'fastify' +import { getUserCtrl } from '../controllers/userController' + +const userRoute: FastifyPluginCallback = (fastify, opts, done) => { + fastify.get('/user/:userId', getUserCtrl) + done() +} + +export default userRoute diff --git a/packages/store-server/src/config/config.example.json b/packages/store-server/src/config/config.example.json new file mode 100644 index 0000000..aa168b7 --- /dev/null +++ b/packages/store-server/src/config/config.example.json @@ -0,0 +1,6 @@ +{ + "port": "", + "secrets": { + "jwt": "" + } +} \ No newline at end of file diff --git a/packages/store-server/src/config/ecosystem.config.js b/packages/store-server/src/config/ecosystem.config.js new file mode 100644 index 0000000..a5ec3a3 --- /dev/null +++ b/packages/store-server/src/config/ecosystem.config.js @@ -0,0 +1,8 @@ +module.exports = { + apps: [ + { + name: 'coldsurf store server', + script: 'node ./dist/server.js', + }, + ], +} diff --git a/packages/store-server/src/server.ts b/packages/store-server/src/server.ts new file mode 100644 index 0000000..95fe7e1 --- /dev/null +++ b/packages/store-server/src/server.ts @@ -0,0 +1,57 @@ +import Fastify from 'fastify' +import AutoLoad from '@fastify/autoload' +import path from 'path' +import nconf from 'nconf' +import jwt from '@fastify/jwt' +import cors from '@fastify/cors' + +const fastify = Fastify({ + ignoreTrailingSlash: true, + logger: { + level: 'info', + }, +}) + +async function loadSettings() { + return new Promise((resolve, reject) => { + try { + nconf.file({ + file: path.resolve(__dirname, './config/config.json'), + }) + resolve() + } catch (e) { + reject(e) + } + }) +} + +async function main() { + try { + await loadSettings() + await fastify.register(cors, { + origin: + process.env.NODE_ENV === 'development' + ? ['http://localhost:3000'] + : ['https://store.coldsurf.io'], + preflight: true, + methods: ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE'], + }) + await fastify.register(AutoLoad, { + dir: path.resolve(__dirname, './api/routes'), + options: { + prefix: '/api/v1', + }, + }) + await fastify.register(jwt, { + secret: nconf.get('secrets').jwt, + }) + + await fastify.listen({ port: nconf.get('port'), host: '0.0.0.0' }) + fastify.log.info('server started', process.env.NODE_ENV) + } catch (err) { + fastify.log.error(err) + process.exit(1) + } +} + +main() diff --git a/packages/store-server/src/types/auth.ts b/packages/store-server/src/types/auth.ts new file mode 100644 index 0000000..a49e7a8 --- /dev/null +++ b/packages/store-server/src/types/auth.ts @@ -0,0 +1 @@ +export type SocialAuthProvider = 'google' diff --git a/packages/store-server/src/types/fastify-jwt.d.ts b/packages/store-server/src/types/fastify-jwt.d.ts new file mode 100644 index 0000000..2a7b0e1 --- /dev/null +++ b/packages/store-server/src/types/fastify-jwt.d.ts @@ -0,0 +1,14 @@ +// fastify-jwt.d.ts +import '@fastify/jwt' +import { JWTPayload } from './jwt' + +declare module '@fastify/jwt' { + interface FastifyJWT { + payload: JWTPayload // payload type is used for signing and verifying + // user: { + // id: number + // name: string + // age: number + // } // user type is return type of `request.user` object + } +} diff --git a/packages/store-server/src/types/jwt.ts b/packages/store-server/src/types/jwt.ts new file mode 100644 index 0000000..c6be056 --- /dev/null +++ b/packages/store-server/src/types/jwt.ts @@ -0,0 +1,15 @@ +import { SocialAuthProvider } from './auth' + +export type JWTDecoded = { + provider: SocialAuthProvider + email: string + id: string + iat: number + exp: number +} + +export type JWTPayload = { + provider: SocialAuthProvider + email: string + id: string +} diff --git a/packages/store-server/tsconfig.json b/packages/store-server/tsconfig.json new file mode 100644 index 0000000..3f761d9 --- /dev/null +++ b/packages/store-server/tsconfig.json @@ -0,0 +1,109 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/packages/wamuseum-server/package.json b/packages/wamuseum-server/package.json index e3e9a62..0380563 100644 --- a/packages/wamuseum-server/package.json +++ b/packages/wamuseum-server/package.json @@ -25,7 +25,7 @@ "@fastify/jwt": "^7.2.4", "@fastify/multipart": "^8.0.0", "@fastify/static": "^6.12.0", - "@prisma/client": "^5.7.1", + "@prisma/client": "5.8.0", "crypto-js": "^4.2.0", "fastify": "^4.25.2", "google-auth-library": "^9.4.1", diff --git a/yarn.lock b/yarn.lock index 9892ccb..2b52834 100644 --- a/yarn.lock +++ b/yarn.lock @@ -943,7 +943,7 @@ dependencies: text-decoding "^1.0.0" -"@fastify/cors@^8.5.0": +"@fastify/cors@^8.4.2", "@fastify/cors@^8.5.0": version "8.5.0" resolved "https://registry.npmjs.org/@fastify/cors/-/cors-8.5.0.tgz" integrity sha512-/oZ1QSb02XjP0IK1U0IXktEsw/dUBTxJOW7IpIeO8c/tNalw/KjoNSJv1Sf6eqoBPO+TDGkifq6ynFK3v68HFQ== @@ -1619,7 +1619,7 @@ "@pnpm/network.ca-file" "^1.0.1" config-chain "^1.1.11" -"@prisma/client@^5.7.1": +"@prisma/client@5.8.0", "@prisma/client@^5.7.1": version "5.8.0" resolved "https://registry.npmjs.org/@prisma/client/-/client-5.8.0.tgz" integrity sha512-QxO6C4MaA/ysTIbC+EcAH1aX/YkpymhXtO6zPdk+FvA7+59tNibIYpd+7koPdViLg2iKES4ojsxWNUGNJaEcbA== @@ -2437,6 +2437,11 @@ dependencies: "@types/node" "*" +"@types/uuid@8.3.4": + version "8.3.4" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc" + integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw== + "@typescript-eslint/eslint-plugin@^5.21.0", "@typescript-eslint/eslint-plugin@^5.53.0", "@typescript-eslint/eslint-plugin@^5.62.0": version "5.62.0" resolved "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz" @@ -4616,7 +4621,7 @@ fastify-plugin@^4.0.0: resolved "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-4.5.1.tgz" integrity sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ== -fastify@^4.25.2: +fastify@^4.24.3, fastify@^4.25.2: version "4.25.2" resolved "https://registry.npmjs.org/fastify/-/fastify-4.25.2.tgz" integrity sha512-SywRouGleDHvRh054onj+lEZnbC1sBCLkR0UY3oyJwjD4BdZJUrxBqfkfCaqn74pVCwBaRHGuL3nEWeHbHzAfw== @@ -8052,15 +8057,23 @@ util@^0.12.5: is-typed-array "^1.1.3" which-typed-array "^1.1.2" +uuid@8.3.2, uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + uuid@^3.2.1: version "3.4.0" resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== +uuidv4@^6.2.13: + version "6.2.13" + resolved "https://registry.yarnpkg.com/uuidv4/-/uuidv4-6.2.13.tgz#8f95ec5ef22d1f92c8e5d4c70b735d1c89572cb7" + integrity sha512-AXyzMjazYB3ovL3q051VLH06Ixj//Knx7QnUSi1T//Ie3io6CpsPu9nVMOx5MoLWh6xV0B9J0hIaxungxXUbPQ== + dependencies: + "@types/uuid" "8.3.4" + uuid "8.3.2" v8-compile-cache@^2.0.3: version "2.4.0"