refactor: minor changes
This commit is contained in:
parent
ab94d1e656
commit
a6dd112e4a
12
.env.example
12
.env.example
@ -1,21 +1,21 @@
|
|||||||
API_URL=http://localhost:8080
|
|
||||||
COMPOSE_PROJECT_NAME=thream-api
|
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
|
DATABASE_URL=postgresql://user:password@thream-database:5432/thream
|
||||||
DISCORD_CLIENT_ID=
|
|
||||||
DISCORD_CLIENT_SECRET=
|
|
||||||
EMAIL_HOST=thream-maildev
|
EMAIL_HOST=thream-maildev
|
||||||
EMAIL_PASSWORD=password
|
EMAIL_PASSWORD=password
|
||||||
EMAIL_PORT=25
|
EMAIL_PORT=25
|
||||||
EMAIL_USER=no-reply@thream.fr
|
EMAIL_USER=no-reply@thream.fr
|
||||||
FILE_UPLOADS_API_KEY=apiKeySecret
|
FILE_UPLOADS_API_KEY=apiKeySecret
|
||||||
FILE_UPLOADS_API_URL=http://host.docker.internal:8000
|
FILE_UPLOADS_API_URL=http://host.docker.internal:8000
|
||||||
|
DISCORD_CLIENT_ID=
|
||||||
|
DISCORD_CLIENT_SECRET=
|
||||||
GITHUB_CLIENT_ID=
|
GITHUB_CLIENT_ID=
|
||||||
GITHUB_CLIENT_SECRET=
|
GITHUB_CLIENT_SECRET=
|
||||||
GOOGLE_CLIENT_ID=
|
GOOGLE_CLIENT_ID=
|
||||||
GOOGLE_CLIENT_SECRET=
|
GOOGLE_CLIENT_SECRET=
|
||||||
HOST=0.0.0.0
|
|
||||||
JWT_ACCESS_EXPIRES_IN=15 minutes
|
JWT_ACCESS_EXPIRES_IN=15 minutes
|
||||||
JWT_ACCESS_SECRET=accessTokenSecret
|
JWT_ACCESS_SECRET=accessTokenSecret
|
||||||
JWT_REFRESH_SECRET=refreshTokenSecret
|
JWT_REFRESH_SECRET=refreshTokenSecret
|
||||||
NODE_ENV=development
|
|
||||||
PORT=8080
|
|
||||||
|
4
.github/workflows/lint.yml
vendored
4
.github/workflows/lint.yml
vendored
@ -46,7 +46,5 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dockerfile: './Dockerfile'
|
dockerfile: './Dockerfile'
|
||||||
|
|
||||||
- run: 'cp .env.example .env'
|
|
||||||
|
|
||||||
- name: 'prisma:validate'
|
- name: 'prisma:validate'
|
||||||
run: 'npm run prisma:validate'
|
run: 'cp .env.example .env && npm run prisma:validate'
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,3 +35,4 @@ npm-debug.log*
|
|||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
*.hbs
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
build
|
|
||||||
node_modules
|
|
||||||
coverage
|
|
||||||
package.json
|
|
||||||
package-lock.json
|
|
||||||
*.hbs
|
|
14
.swcrc
14
.swcrc
@ -2,21 +2,11 @@
|
|||||||
"jsc": {
|
"jsc": {
|
||||||
"parser": {
|
"parser": {
|
||||||
"syntax": "typescript",
|
"syntax": "typescript",
|
||||||
"decorators": true,
|
|
||||||
"dynamicImport": true
|
"dynamicImport": true
|
||||||
},
|
},
|
||||||
"transform": {
|
"target": "es2022"
|
||||||
"legacyDecorator": true,
|
|
||||||
"decoratorMetadata": true
|
|
||||||
},
|
|
||||||
"target": "es2022",
|
|
||||||
"loose": true
|
|
||||||
},
|
},
|
||||||
"module": {
|
"module": {
|
||||||
"type": "es6",
|
"type": "es6"
|
||||||
"strict": false,
|
|
||||||
"strictMode": true,
|
|
||||||
"lazy": false,
|
|
||||||
"noInterop": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export const serviceGenerator = {
|
|||||||
type: 'list',
|
type: 'list',
|
||||||
name: 'tag',
|
name: 'tag',
|
||||||
message: 'tag',
|
message: 'tag',
|
||||||
choices: ['users', 'guilds', 'channels', 'messages', 'members', 'uploads']
|
choices: ['users', 'guilds', 'channels', 'messages', 'members']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
|
898
package-lock.json
generated
898
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@ -22,7 +22,7 @@
|
|||||||
"lint:editorconfig": "editorconfig-checker",
|
"lint:editorconfig": "editorconfig-checker",
|
||||||
"lint:markdown": "markdownlint-cli2",
|
"lint:markdown": "markdownlint-cli2",
|
||||||
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
|
"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",
|
"lint:staged": "lint-staged",
|
||||||
"test": "cross-env NODE_ENV=test c8 tap",
|
"test": "cross-env NODE_ENV=test c8 tap",
|
||||||
"prisma:validate": "prisma validate",
|
"prisma:validate": "prisma validate",
|
||||||
@ -36,9 +36,9 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/cors": "8.1.0",
|
"@fastify/cors": "8.1.0",
|
||||||
"@fastify/helmet": "9.1.0",
|
"@fastify/helmet": "9.1.0",
|
||||||
"@fastify/multipart": "7.1.0",
|
"@fastify/multipart": "7.1.1",
|
||||||
"@fastify/rate-limit": "7.3.0",
|
"@fastify/rate-limit": "7.3.0",
|
||||||
"@fastify/sensible": "5.1.0",
|
"@fastify/sensible": "5.1.1",
|
||||||
"@fastify/swagger": "7.4.1",
|
"@fastify/swagger": "7.4.1",
|
||||||
"@prisma/client": "4.2.1",
|
"@prisma/client": "4.2.1",
|
||||||
"@sinclair/typebox": "0.24.28",
|
"@sinclair/typebox": "0.24.28",
|
||||||
@ -47,8 +47,8 @@
|
|||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"dotenv": "16.0.1",
|
"dotenv": "16.0.1",
|
||||||
"ejs": "3.1.8",
|
"ejs": "3.1.8",
|
||||||
"fastify": "4.5.2",
|
"fastify": "4.5.3",
|
||||||
"fastify-plugin": "4.2.0",
|
"fastify-plugin": "4.2.1",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
"http-errors": "2.0.0",
|
"http-errors": "2.0.0",
|
||||||
"jsonwebtoken": "8.5.1",
|
"jsonwebtoken": "8.5.1",
|
||||||
@ -58,33 +58,34 @@
|
|||||||
"socket.io": "4.5.1"
|
"socket.io": "4.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "17.0.3",
|
"@commitlint/cli": "17.1.2",
|
||||||
"@commitlint/config-conventional": "17.0.3",
|
"@commitlint/config-conventional": "17.1.0",
|
||||||
"@saithodev/semantic-release-backmerge": "2.1.2",
|
"@saithodev/semantic-release-backmerge": "2.1.2",
|
||||||
"@semantic-release/git": "10.0.1",
|
"@semantic-release/git": "10.0.1",
|
||||||
"@swc/cli": "0.1.57",
|
"@swc/cli": "0.1.57",
|
||||||
"@swc/core": "1.2.242",
|
"@swc/core": "1.2.244",
|
||||||
"@types/bcryptjs": "2.4.2",
|
"@types/bcryptjs": "2.4.2",
|
||||||
"@types/busboy": "1.5.0",
|
"@types/busboy": "1.5.0",
|
||||||
"@types/ejs": "3.1.1",
|
"@types/ejs": "3.1.1",
|
||||||
"@types/http-errors": "1.8.2",
|
"@types/http-errors": "1.8.2",
|
||||||
"@types/jsonwebtoken": "8.5.8",
|
"@types/jsonwebtoken": "8.5.9",
|
||||||
"@types/ms": "0.7.31",
|
"@types/ms": "0.7.31",
|
||||||
"@types/node": "18.7.11",
|
"@types/node": "18.7.13",
|
||||||
"@types/nodemailer": "6.4.5",
|
"@types/nodemailer": "6.4.5",
|
||||||
"@types/sinon": "10.0.13",
|
"@types/sinon": "10.0.13",
|
||||||
"@types/tap": "15.0.7",
|
"@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",
|
"c8": "7.12.0",
|
||||||
"concurrently": "7.3.0",
|
"concurrently": "7.3.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"editorconfig-checker": "4.0.2",
|
"editorconfig-checker": "4.0.2",
|
||||||
"eslint": "8.22.0",
|
"eslint": "8.23.0",
|
||||||
"eslint-config-conventions": "3.0.0",
|
"eslint-config-conventions": "3.0.0",
|
||||||
"eslint-config-prettier": "8.5.0",
|
"eslint-config-prettier": "8.5.0",
|
||||||
"eslint-plugin-import": "2.26.0",
|
"eslint-plugin-import": "2.26.0",
|
||||||
"eslint-plugin-prettier": "4.2.1",
|
"eslint-plugin-prettier": "4.2.1",
|
||||||
"eslint-plugin-promise": "6.0.0",
|
"eslint-plugin-promise": "6.0.1",
|
||||||
"eslint-plugin-unicorn": "43.0.2",
|
"eslint-plugin-unicorn": "43.0.2",
|
||||||
"husky": "8.0.1",
|
"husky": "8.0.1",
|
||||||
"lint-staged": "13.0.3",
|
"lint-staged": "13.0.3",
|
||||||
@ -97,6 +98,6 @@
|
|||||||
"semantic-release": "19.0.5",
|
"semantic-release": "19.0.5",
|
||||||
"sinon": "14.0.0",
|
"sinon": "14.0.0",
|
||||||
"tap": "16.3.0",
|
"tap": "16.3.0",
|
||||||
"typescript": "4.7.4"
|
"typescript": "4.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ export const getUserById: FastifyPluginAsync = async (fastify) => {
|
|||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
email: settings.isPublicEmail,
|
email: settings.isPublicEmail,
|
||||||
|
isConfirmed: true,
|
||||||
logo: true,
|
logo: true,
|
||||||
status: true,
|
status: true,
|
||||||
biography: true,
|
biography: true,
|
||||||
|
@ -80,8 +80,8 @@ export default fastifyPlugin(
|
|||||||
emitToAuthorizedUsers,
|
emitToAuthorizedUsers,
|
||||||
emitToMembers
|
emitToMembers
|
||||||
}
|
}
|
||||||
await fastify.decorate('io', io)
|
fastify.decorate('io', io)
|
||||||
await fastify.addHook('onClose', (fastify) => {
|
fastify.addHook('onClose', (fastify) => {
|
||||||
fastify.io.instance.close()
|
fastify.io.instance.close()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -22,7 +22,7 @@ export const jwtSchema = {
|
|||||||
refreshToken: Type.String(),
|
refreshToken: Type.String(),
|
||||||
expiresIn: Type.Integer({
|
expiresIn: Type.Integer({
|
||||||
description:
|
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')
|
type: Type.Literal('Bearer')
|
||||||
}
|
}
|
||||||
@ -30,9 +30,7 @@ export const jwtSchema = {
|
|||||||
export const expiresIn = ms(JWT_ACCESS_EXPIRES_IN)
|
export const expiresIn = ms(JWT_ACCESS_EXPIRES_IN)
|
||||||
|
|
||||||
export const generateAccessToken = (user: UserJWT): string => {
|
export const generateAccessToken = (user: UserJWT): string => {
|
||||||
return jwt.sign(user, JWT_ACCESS_SECRET, {
|
return jwt.sign(user, JWT_ACCESS_SECRET, { expiresIn })
|
||||||
expiresIn: JWT_ACCESS_EXPIRES_IN
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generateRefreshToken = async (user: UserJWT): Promise<string> => {
|
export const generateRefreshToken = async (user: UserJWT): Promise<string> => {
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"lib": ["ESNext"],
|
"lib": ["ESNext"],
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "Node",
|
||||||
"outDir": "./build",
|
"outDir": "./build",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true
|
||||||
},
|
}
|
||||||
"exclude": ["node_modules", "generators"]
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user