fix: schemaValidationMessages errors in Swagger docs
This commit is contained in:
		
							
								
								
									
										2269
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2269
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										49
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								package.json
									
									
									
									
									
								
							| @@ -18,6 +18,7 @@ | ||||
|     "start": "node build/index.js", | ||||
|     "dev": "concurrently -k -n \"TypeScript,Node\" -p \"[{name}]\" -c \"blue,green\" \"npm run build:dev\" \"cross-env NODE_ENV=development nodemon build/index.js\"", | ||||
|     "generate": "plop", | ||||
|     "generate:jwt-secret": "node ./build/scripts/generate-jwt-secret.js", | ||||
|     "lint:commit": "commitlint", | ||||
|     "lint:editorconfig": "editorconfig-checker", | ||||
|     "lint:markdown": "markdownlint-cli2", | ||||
| @@ -35,27 +36,27 @@ | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@fastify/cors": "8.1.0", | ||||
|     "@fastify/helmet": "9.1.0", | ||||
|     "@fastify/multipart": "7.1.1", | ||||
|     "@fastify/rate-limit": "7.3.0", | ||||
|     "@fastify/helmet": "10.0.1", | ||||
|     "@fastify/multipart": "7.2.0", | ||||
|     "@fastify/rate-limit": "7.4.0", | ||||
|     "@fastify/sensible": "5.1.1", | ||||
|     "@fastify/swagger": "7.4.1", | ||||
|     "@prisma/client": "4.2.1", | ||||
|     "@sinclair/typebox": "0.24.28", | ||||
|     "@thream/socketio-jwt": "3.0.0", | ||||
|     "@fastify/swagger": "7.6.1", | ||||
|     "@prisma/client": "4.4.0", | ||||
|     "@sinclair/typebox": "0.24.44", | ||||
|     "@thream/socketio-jwt": "3.0.1", | ||||
|     "axios": "0.26.1", | ||||
|     "bcryptjs": "2.4.3", | ||||
|     "dotenv": "16.0.1", | ||||
|     "dotenv": "16.0.3", | ||||
|     "ejs": "3.1.8", | ||||
|     "fastify": "4.5.3", | ||||
|     "fastify": "4.7.0", | ||||
|     "fastify-plugin": "4.2.1", | ||||
|     "form-data": "4.0.0", | ||||
|     "http-errors": "2.0.0", | ||||
|     "jsonwebtoken": "8.5.1", | ||||
|     "ms": "2.1.3", | ||||
|     "nodemailer": "6.7.8", | ||||
|     "nodemailer": "6.8.0", | ||||
|     "read-pkg": "7.1.0", | ||||
|     "socket.io": "4.5.1" | ||||
|     "socket.io": "4.5.2" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@commitlint/cli": "17.1.2", | ||||
| @@ -63,41 +64,41 @@ | ||||
|     "@saithodev/semantic-release-backmerge": "2.1.2", | ||||
|     "@semantic-release/git": "10.0.1", | ||||
|     "@swc/cli": "0.1.57", | ||||
|     "@swc/core": "1.2.244", | ||||
|     "@swc/core": "1.3.4", | ||||
|     "@types/bcryptjs": "2.4.2", | ||||
|     "@types/busboy": "1.5.0", | ||||
|     "@types/ejs": "3.1.1", | ||||
|     "@types/http-errors": "1.8.2", | ||||
|     "@types/jsonwebtoken": "8.5.9", | ||||
|     "@types/ms": "0.7.31", | ||||
|     "@types/node": "18.7.13", | ||||
|     "@types/nodemailer": "6.4.5", | ||||
|     "@types/node": "18.8.1", | ||||
|     "@types/nodemailer": "6.4.6", | ||||
|     "@types/sinon": "10.0.13", | ||||
|     "@types/tap": "15.0.7", | ||||
|     "@typescript-eslint/eslint-plugin": "5.35.1", | ||||
|     "@typescript-eslint/parser": "5.35.1", | ||||
|     "@typescript-eslint/eslint-plugin": "5.39.0", | ||||
|     "@typescript-eslint/parser": "5.39.0", | ||||
|     "c8": "7.12.0", | ||||
|     "concurrently": "7.3.0", | ||||
|     "concurrently": "7.4.0", | ||||
|     "cross-env": "7.0.3", | ||||
|     "editorconfig-checker": "4.0.2", | ||||
|     "eslint": "8.23.0", | ||||
|     "eslint-config-conventions": "3.0.0", | ||||
|     "eslint": "8.24.0", | ||||
|     "eslint-config-conventions": "5.0.0", | ||||
|     "eslint-config-prettier": "8.5.0", | ||||
|     "eslint-plugin-import": "2.26.0", | ||||
|     "eslint-plugin-prettier": "4.2.1", | ||||
|     "eslint-plugin-promise": "6.0.1", | ||||
|     "eslint-plugin-unicorn": "43.0.2", | ||||
|     "eslint-plugin-unicorn": "44.0.0", | ||||
|     "husky": "8.0.1", | ||||
|     "lint-staged": "13.0.3", | ||||
|     "markdownlint-cli2": "0.5.1", | ||||
|     "nodemon": "2.0.19", | ||||
|     "nodemon": "2.0.20", | ||||
|     "plop": "3.1.1", | ||||
|     "prettier": "2.7.1", | ||||
|     "prisma": "4.2.1", | ||||
|     "prisma": "4.4.0", | ||||
|     "rimraf": "3.0.2", | ||||
|     "semantic-release": "19.0.5", | ||||
|     "sinon": "14.0.0", | ||||
|     "sinon": "14.0.1", | ||||
|     "tap": "16.3.0", | ||||
|     "typescript": "4.8.2" | ||||
|     "typescript": "4.8.4" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,9 @@ | ||||
| import { User } from '@prisma/client' | ||||
| import type { User } from '@prisma/client' | ||||
| import sinon from 'sinon' | ||||
|  | ||||
| import { refreshTokenExample } from '../../models/RefreshToken.js' | ||||
| import { userExample, UserJWT } from '../../models/User.js' | ||||
| import type { UserJWT } from '../../models/User.js' | ||||
| import { userExample } from '../../models/User.js' | ||||
| import { userSettingsExample } from '../../models/UserSettings.js' | ||||
| import { | ||||
|   generateAccessToken, | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import { Channel } from '@prisma/client' | ||||
| import type { Channel } from '@prisma/client' | ||||
|  | ||||
| import { date, id } from './utils.js' | ||||
| import { guildExample } from './Guild.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { Guild } from '@prisma/client' | ||||
| import type { Guild } from '@prisma/client' | ||||
| import { Type } from '@sinclair/typebox' | ||||
|  | ||||
| import { date, id } from './utils.js' | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import { Member } from '@prisma/client' | ||||
| import type { Member } from '@prisma/client' | ||||
|  | ||||
| import { date, id } from './utils.js' | ||||
| import { guildExample } from './Guild.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { Message } from '@prisma/client' | ||||
| import type { Message } from '@prisma/client' | ||||
| import { Type } from '@sinclair/typebox' | ||||
|  | ||||
| import { date, id } from './utils.js' | ||||
|   | ||||
| @@ -5,12 +5,12 @@ import { date, id } from './utils.js' | ||||
| export const providers = ['Google', 'GitHub', 'Discord'] as const | ||||
| export const strategies = [...providers, 'Local'] as const | ||||
|  | ||||
| export const strategiesTypebox = strategies.map((strategy) => | ||||
|   Type.Literal(strategy) | ||||
| ) | ||||
| export const providersTypebox = providers.map((provider) => | ||||
|   Type.Literal(provider) | ||||
| ) | ||||
| export const strategiesTypebox = strategies.map((strategy) => { | ||||
|   return Type.Literal(strategy) | ||||
| }) | ||||
| export const providersTypebox = providers.map((provider) => { | ||||
|   return Type.Literal(provider) | ||||
| }) | ||||
|  | ||||
| export type ProviderOAuth = typeof providers[number] | ||||
| export type AuthenticationStrategy = typeof strategies[number] | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { RefreshToken } from '@prisma/client' | ||||
| import type { RefreshToken } from '@prisma/client' | ||||
| import { Type } from '@sinclair/typebox' | ||||
|  | ||||
| import { userExample } from './User.js' | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| import { User } from '@prisma/client' | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import type { User } from '@prisma/client' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
|  | ||||
| import { AuthenticationStrategy, strategiesTypebox } from './OAuth.js' | ||||
| import type { AuthenticationStrategy } from './OAuth.js' | ||||
| import { strategiesTypebox } from './OAuth.js' | ||||
| import { userSettingsSchema } from './UserSettings.js' | ||||
| import { date, id } from './utils.js' | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { UserSetting } from '@prisma/client' | ||||
| import { Type, Static } from '@sinclair/typebox' | ||||
| import type { UserSetting } from '@prisma/client' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
|  | ||||
| import { date, id } from './utils.js' | ||||
|  | ||||
|   | ||||
| @@ -34,7 +34,7 @@ export const fastifyErrorsSchema = { | ||||
|   404: { | ||||
|     statusCode: Type.Literal(404), | ||||
|     error: Type.Literal('Not Found'), | ||||
|     message: Type.Literal('Not Found') | ||||
|     message: Type.String() | ||||
|   }, | ||||
|   431: { | ||||
|     statusCode: Type.Literal(431), | ||||
|   | ||||
							
								
								
									
										3
									
								
								src/scripts/generate-jwt-secret.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/scripts/generate-jwt-secret.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| import crypto from 'node:crypto' | ||||
|  | ||||
| console.log(crypto.randomBytes(256).toString('base64')) | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Type, Static } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import fastifyMultipart from '@fastify/multipart' | ||||
|  | ||||
| import prisma from '../../../../../tools/database/prisma.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { FastifyPluginAsync } from 'fastify' | ||||
| import type { FastifyPluginAsync } from 'fastify' | ||||
|  | ||||
| import { deleteChannelService } from './[channelId]/delete.js' | ||||
| import { getChannelByIdService } from './[channelId]/get.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import fastifyMultipart from '@fastify/multipart' | ||||
|  | ||||
| import authenticateUser from '../../../../tools/plugins/authenticateUser.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../../tools/database/prisma.js' | ||||
| import { | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Type, Static } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../tools/database/prisma.js' | ||||
| import { fastifyErrors, id } from '../../models/utils.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { FastifyPluginAsync } from 'fastify' | ||||
| import type { FastifyPluginAsync } from 'fastify' | ||||
|  | ||||
| import { getGuilds } from './get.js' | ||||
| import { postGuilds } from './post.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { FastifyPluginAsync } from 'fastify' | ||||
| import type { FastifyPluginAsync } from 'fastify' | ||||
|  | ||||
| import { usersService } from './users/index.js' | ||||
| import { guildsService } from './guilds/index.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { FastifyPluginAsync } from 'fastify' | ||||
| import type { FastifyPluginAsync } from 'fastify' | ||||
|  | ||||
| import { deleteMessageService } from './[messageId]/delete.js' | ||||
| import { putMessageService } from './[messageId]/put.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import fastifyMultipart from '@fastify/multipart' | ||||
|  | ||||
| import authenticateUser from '../../../../tools/plugins/authenticateUser.js' | ||||
|   | ||||
| @@ -1,7 +1,8 @@ | ||||
| import { randomUUID } from 'node:crypto' | ||||
|  | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
| @@ -9,7 +10,7 @@ import authenticateUser from '../../../tools/plugins/authenticateUser.js' | ||||
| import { userCurrentSchema, userSchema } from '../../../models/User.js' | ||||
| import { sendEmail } from '../../../tools/email/sendEmail.js' | ||||
| import { API_URL } from '../../../tools/configurations/index.js' | ||||
| import { Language, Theme } from '../../../models/UserSettings.js' | ||||
| import type { Language, Theme } from '../../../models/UserSettings.js' | ||||
| import { parseStringNullish } from '../../../tools/utils/parseStringNullish.js' | ||||
|  | ||||
| const bodyPutServiceSchema = Type.Object({ | ||||
| @@ -136,7 +137,9 @@ export const putCurrentUser: FastifyPluginAsync = async (fastify) => { | ||||
|       }) | ||||
|       await fastify.io.emitToAuthorizedUsers({ | ||||
|         event: 'users', | ||||
|         isAuthorizedCallback: () => true, | ||||
|         isAuthorizedCallback: () => { | ||||
|           return true | ||||
|         }, | ||||
|         payload: { | ||||
|           action: 'update', | ||||
|           item: user | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { FastifyPluginAsync } from 'fastify' | ||||
| import type { FastifyPluginAsync } from 'fastify' | ||||
|  | ||||
| import { postSignupUser } from './signup/post.js' | ||||
| import { getConfirmEmail } from './confirm-email/get.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../../models/utils.js' | ||||
| @@ -55,7 +56,9 @@ export const deleteProviderService: FastifyPluginAsync = async (fastify) => { | ||||
|       if (user.current.password != null) { | ||||
|         strategies.push('Local') | ||||
|       } | ||||
|       const oauthProvider = OAuths.find((oauth) => oauth.provider === provider) | ||||
|       const oauthProvider = OAuths.find((oauth) => { | ||||
|         return oauth.provider === provider | ||||
|       }) | ||||
|       if (oauthProvider == null) { | ||||
|         throw fastify.httpErrors.notFound('You are not using this provider') | ||||
|       } | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import jwt from 'jsonwebtoken' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| @@ -9,7 +10,7 @@ import { | ||||
|   jwtSchema, | ||||
|   expiresIn | ||||
| } from '../../../tools/utils/jwtToken.js' | ||||
| import { UserRefreshJWT } from '../../../models/User.js' | ||||
| import type { UserRefreshJWT } from '../../../models/User.js' | ||||
| import { JWT_REFRESH_SECRET } from '../../../tools/configurations/index.js' | ||||
|  | ||||
| const bodyPostRefreshTokenSchema = Type.Object({ | ||||
|   | ||||
| @@ -1,14 +1,15 @@ | ||||
| import { randomUUID } from 'node:crypto' | ||||
|  | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import ms from 'ms' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
| import { userSchema } from '../../../models/User.js' | ||||
| import { sendEmail } from '../../../tools/email/sendEmail.js' | ||||
| import { Language, Theme } from '../../../models/UserSettings.js' | ||||
| import type { Language, Theme } from '../../../models/UserSettings.js' | ||||
|  | ||||
| const queryPostResetPasswordSchema = Type.Object({ | ||||
|   redirectURI: Type.String({ format: 'uri-reference' }) | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import bcrypt from 'bcryptjs' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import bcrypt from 'bcryptjs' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import jwt from 'jsonwebtoken' | ||||
| import { application } from '../../../../application.js' | ||||
| import prisma from '../../../../tools/database/prisma.js' | ||||
| import { refreshTokenExample } from '../../../../models/RefreshToken.js' | ||||
| import { UserRefreshJWT } from '../../../../models/User.js' | ||||
| import type { UserRefreshJWT } from '../../../../models/User.js' | ||||
|  | ||||
| await tap.test('POST /users/signout', async (t) => { | ||||
|   t.afterEach(() => { | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
|   | ||||
| @@ -1,11 +1,12 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import jwt from 'jsonwebtoken' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
| import { JWT_REFRESH_SECRET } from '../../../tools/configurations/index.js' | ||||
| import { UserRefreshJWT } from '../../../models/User.js' | ||||
| import type { UserRefreshJWT } from '../../../models/User.js' | ||||
| import { jwtSchema } from '../../../tools/utils/jwtToken.js' | ||||
|  | ||||
| const bodyPostSignoutSchema = Type.Object({ | ||||
|   | ||||
| @@ -1,16 +1,14 @@ | ||||
| import { randomUUID } from 'node:crypto' | ||||
|  | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
| import bcrypt from 'bcryptjs' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
| import type { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import prisma from '../../../tools/database/prisma.js' | ||||
| import { fastifyErrors } from '../../../models/utils.js' | ||||
| import { | ||||
|   bodyUserSchema, | ||||
|   BodyUserSchemaType, | ||||
|   userPublicSchema | ||||
| } from '../../../models/User.js' | ||||
| import type { BodyUserSchemaType } from '../../../models/User.js' | ||||
| import { bodyUserSchema, userPublicSchema } from '../../../models/User.js' | ||||
| import { sendEmail } from '../../../tools/email/sendEmail.js' | ||||
| import { API_URL } from '../../../tools/configurations/index.js' | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import dotenv from 'dotenv' | ||||
| import { readPackage } from 'read-pkg' | ||||
| import { FastifyDynamicSwaggerOptions } from '@fastify/swagger' | ||||
| import type { FastifyDynamicSwaggerOptions } from '@fastify/swagger' | ||||
|  | ||||
| dotenv.config() | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { Prisma } from '@prisma/client' | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import type { Prisma } from '@prisma/client' | ||||
| import type { Static } from '@sinclair/typebox' | ||||
| import { Type } from '@sinclair/typebox' | ||||
|  | ||||
| export const queryPaginationSchema = { | ||||
|   /** Maximum number of items to return */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import { URL, fileURLToPath } from 'node:url' | ||||
|  | ||||
| import ejs from 'ejs' | ||||
|  | ||||
| import { Language, Theme } from '../../models/UserSettings.js' | ||||
| import type { Language, Theme } from '../../models/UserSettings.js' | ||||
| import { | ||||
|   EMAIL_LOCALES_URL, | ||||
|   EMAIL_TEMPLATE_URL | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import httpErrors from 'http-errors' | ||||
| import jwt from 'jsonwebtoken' | ||||
|  | ||||
| import prisma from '../database/prisma.js' | ||||
| import { UserJWT, UserRequest } from '../../models/User.js' | ||||
| import type { UserJWT, UserRequest } from '../../models/User.js' | ||||
| import { JWT_ACCESS_SECRET } from '../configurations/index.js' | ||||
|  | ||||
| const { Unauthorized, Forbidden, BadRequest } = httpErrors | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import fastifyPlugin from 'fastify-plugin' | ||||
| import { Server as SocketIoServer, ServerOptions } from 'socket.io' | ||||
| import type { ServerOptions } from 'socket.io' | ||||
| import { Server as SocketIoServer } from 'socket.io' | ||||
| import { authorize } from '@thream/socketio-jwt' | ||||
|  | ||||
| import prisma from '../database/prisma.js' | ||||
|   | ||||
| @@ -1,12 +1,12 @@ | ||||
| import type { ResponseJWT } from './jwtToken.js' | ||||
| import { | ||||
|   expiresIn, | ||||
|   generateAccessToken, | ||||
|   generateRefreshToken, | ||||
|   ResponseJWT | ||||
|   generateRefreshToken | ||||
| } from './jwtToken.js' | ||||
| import prisma from '../database/prisma.js' | ||||
| import { ProviderOAuth } from '../../models/OAuth.js' | ||||
| import { UserRequest } from '../../models/User.js' | ||||
| import type { ProviderOAuth } from '../../models/OAuth.js' | ||||
| import type { UserRequest } from '../../models/User.js' | ||||
|  | ||||
| interface ProviderData { | ||||
|   name: string | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import jwt from 'jsonwebtoken' | ||||
| import ms from 'ms' | ||||
|  | ||||
| import prisma from '../database/prisma.js' | ||||
| import { UserJWT } from '../../models/User.js' | ||||
| import type { UserJWT } from '../../models/User.js' | ||||
| import { | ||||
|   JWT_ACCESS_EXPIRES_IN, | ||||
|   JWT_ACCESS_SECRET, | ||||
|   | ||||
| @@ -2,8 +2,8 @@ import fs from 'node:fs' | ||||
|  | ||||
| import axios from 'axios' | ||||
| import FormData from 'form-data' | ||||
| import { FastifyInstance, FastifyRequest } from 'fastify' | ||||
| import { Multipart } from '@fastify/multipart' | ||||
| import type { FastifyInstance, FastifyRequest } from 'fastify' | ||||
| import type { SavedMultipartFile } from '@fastify/multipart' | ||||
|  | ||||
| import { | ||||
|   FILE_UPLOADS_API_KEY, | ||||
| @@ -35,7 +35,7 @@ export const uploadFile = async ( | ||||
|   options: UploadFileOptions | ||||
| ): Promise<UploadFileResult> => { | ||||
|   const { fastify, request, folderInUploadsFolder } = options | ||||
|   let files: Multipart[] = [] | ||||
|   let files: SavedMultipartFile[] = [] | ||||
|   try { | ||||
|     files = await request.saveRequestFiles({ | ||||
|       limits: { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user