refactor: minor changes

This commit is contained in:
Divlo 2022-08-29 16:10:17 +00:00
parent ab94d1e656
commit a6dd112e4a
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
12 changed files with 468 additions and 515 deletions

View File

@ -1,21 +1,21 @@
API_URL=http://localhost:8080
COMPOSE_PROJECT_NAME=thream-api
NODE_ENV=development
API_URL=http://localhost:8080
HOST=0.0.0.0
PORT=8080
DATABASE_URL=postgresql://user:password@thream-database:5432/thream
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
EMAIL_HOST=thream-maildev
EMAIL_PASSWORD=password
EMAIL_PORT=25
EMAIL_USER=no-reply@thream.fr
FILE_UPLOADS_API_KEY=apiKeySecret
FILE_UPLOADS_API_URL=http://host.docker.internal:8000
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
HOST=0.0.0.0
JWT_ACCESS_EXPIRES_IN=15 minutes
JWT_ACCESS_SECRET=accessTokenSecret
JWT_REFRESH_SECRET=refreshTokenSecret
NODE_ENV=development
PORT=8080

View File

@ -46,7 +46,5 @@ jobs:
with:
dockerfile: './Dockerfile'
- run: 'cp .env.example .env'
- name: 'prisma:validate'
run: 'npm run prisma:validate'
run: 'cp .env.example .env && npm run prisma:validate'

1
.gitignore vendored
View File

@ -35,3 +35,4 @@ npm-debug.log*
# misc
.DS_Store
*.hbs

View File

@ -1,6 +0,0 @@
build
node_modules
coverage
package.json
package-lock.json
*.hbs

14
.swcrc
View File

@ -2,21 +2,11 @@
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"target": "es2022",
"loose": true
"target": "es2022"
},
"module": {
"type": "es6",
"strict": false,
"strictMode": true,
"lazy": false,
"noInterop": false
"type": "es6"
}
}

View File

@ -22,7 +22,7 @@ export const serviceGenerator = {
type: 'list',
name: 'tag',
message: 'tag',
choices: ['users', 'guilds', 'channels', 'messages', 'members', 'uploads']
choices: ['users', 'guilds', 'channels', 'messages', 'members']
},
{
type: 'confirm',

898
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
"lint:editorconfig": "editorconfig-checker",
"lint:markdown": "markdownlint-cli2",
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
"lint:prettier": "prettier \".\" --check",
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
"lint:staged": "lint-staged",
"test": "cross-env NODE_ENV=test c8 tap",
"prisma:validate": "prisma validate",
@ -36,9 +36,9 @@
"dependencies": {
"@fastify/cors": "8.1.0",
"@fastify/helmet": "9.1.0",
"@fastify/multipart": "7.1.0",
"@fastify/multipart": "7.1.1",
"@fastify/rate-limit": "7.3.0",
"@fastify/sensible": "5.1.0",
"@fastify/sensible": "5.1.1",
"@fastify/swagger": "7.4.1",
"@prisma/client": "4.2.1",
"@sinclair/typebox": "0.24.28",
@ -47,8 +47,8 @@
"bcryptjs": "2.4.3",
"dotenv": "16.0.1",
"ejs": "3.1.8",
"fastify": "4.5.2",
"fastify-plugin": "4.2.0",
"fastify": "4.5.3",
"fastify-plugin": "4.2.1",
"form-data": "4.0.0",
"http-errors": "2.0.0",
"jsonwebtoken": "8.5.1",
@ -58,33 +58,34 @@
"socket.io": "4.5.1"
},
"devDependencies": {
"@commitlint/cli": "17.0.3",
"@commitlint/config-conventional": "17.0.3",
"@commitlint/cli": "17.1.2",
"@commitlint/config-conventional": "17.1.0",
"@saithodev/semantic-release-backmerge": "2.1.2",
"@semantic-release/git": "10.0.1",
"@swc/cli": "0.1.57",
"@swc/core": "1.2.242",
"@swc/core": "1.2.244",
"@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.8",
"@types/jsonwebtoken": "8.5.9",
"@types/ms": "0.7.31",
"@types/node": "18.7.11",
"@types/node": "18.7.13",
"@types/nodemailer": "6.4.5",
"@types/sinon": "10.0.13",
"@types/tap": "15.0.7",
"@typescript-eslint/eslint-plugin": "5.34.0",
"@typescript-eslint/eslint-plugin": "5.35.1",
"@typescript-eslint/parser": "5.35.1",
"c8": "7.12.0",
"concurrently": "7.3.0",
"cross-env": "7.0.3",
"editorconfig-checker": "4.0.2",
"eslint": "8.22.0",
"eslint": "8.23.0",
"eslint-config-conventions": "3.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.0",
"eslint-plugin-promise": "6.0.1",
"eslint-plugin-unicorn": "43.0.2",
"husky": "8.0.1",
"lint-staged": "13.0.3",
@ -97,6 +98,6 @@
"semantic-release": "19.0.5",
"sinon": "14.0.0",
"tap": "16.3.0",
"typescript": "4.7.4"
"typescript": "4.8.2"
}
}

View File

@ -50,6 +50,7 @@ export const getUserById: FastifyPluginAsync = async (fastify) => {
id: true,
name: true,
email: settings.isPublicEmail,
isConfirmed: true,
logo: true,
status: true,
biography: true,

View File

@ -80,8 +80,8 @@ export default fastifyPlugin(
emitToAuthorizedUsers,
emitToMembers
}
await fastify.decorate('io', io)
await fastify.addHook('onClose', (fastify) => {
fastify.decorate('io', io)
fastify.addHook('onClose', (fastify) => {
fastify.io.instance.close()
})
},

View File

@ -22,7 +22,7 @@ export const jwtSchema = {
refreshToken: Type.String(),
expiresIn: Type.Integer({
description:
'expiresIn is how long, in milliseconds, until the returned accessToken expires'
'expiresIn is how long, in milliseconds, until the accessToken expires'
}),
type: Type.Literal('Bearer')
}
@ -30,9 +30,7 @@ export const jwtSchema = {
export const expiresIn = ms(JWT_ACCESS_EXPIRES_IN)
export const generateAccessToken = (user: UserJWT): string => {
return jwt.sign(user, JWT_ACCESS_SECRET, {
expiresIn: JWT_ACCESS_EXPIRES_IN
})
return jwt.sign(user, JWT_ACCESS_SECRET, { expiresIn })
}
export const generateRefreshToken = async (user: UserJWT): Promise<string> => {

View File

@ -3,12 +3,12 @@
"target": "ESNext",
"module": "ESNext",
"lib": ["ESNext"],
"moduleResolution": "node",
"moduleResolution": "Node",
"outDir": "./build",
"rootDir": "./src",
"noEmit": true,
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true
},
"exclude": ["node_modules", "generators"]
}
}