Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
10110d1a36 | |||
73d2da66b2 | |||
b07a62de8b | |||
8a327eb7c7 | |||
78d7dbdb3f | |||
e30a66eeb6 | |||
12dcabccb3 | |||
224d3b3764 | |||
fdecf5ce1a | |||
6926132a1b |
@ -1,7 +1,3 @@
|
|||||||
{
|
{
|
||||||
"extends": ["@commitlint/config-conventional"],
|
"extends": ["@commitlint/config-conventional"]
|
||||||
"rules": {
|
|
||||||
"body-max-length": [0, "always"],
|
|
||||||
"body-max-line-length": [0, "always"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
FROM mcr.microsoft.com/devcontainers/javascript-node:16
|
FROM mcr.microsoft.com/devcontainers/javascript-node:18
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
"dockerComposeFile": "./docker-compose.yml",
|
"dockerComposeFile": "./docker-compose.yml",
|
||||||
"service": "workspace",
|
"service": "workspace",
|
||||||
"workspaceFolder": "/workspace",
|
"workspaceFolder": "/workspace",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
"settings": {
|
"settings": {
|
||||||
"remote.autoForwardPorts": false
|
"remote.autoForwardPorts": false
|
||||||
},
|
},
|
||||||
@ -14,7 +16,9 @@
|
|||||||
"prisma.prisma",
|
"prisma.prisma",
|
||||||
"mikestead.dotenv",
|
"mikestead.dotenv",
|
||||||
"ms-azuretools.vscode-docker"
|
"ms-azuretools.vscode-docker"
|
||||||
],
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"forwardPorts": [8080, 5555, 5432, 1080],
|
"forwardPorts": [8080, 5555, 5432, 1080],
|
||||||
"postAttachCommand": ["npm", "install"],
|
"postAttachCommand": ["npm", "install"],
|
||||||
"remoteUser": "node"
|
"remoteUser": "node"
|
||||||
|
@ -12,7 +12,7 @@ services:
|
|||||||
- 'host.docker.internal:host-gateway'
|
- 'host.docker.internal:host-gateway'
|
||||||
|
|
||||||
thream-database:
|
thream-database:
|
||||||
image: 'postgres:14.5'
|
image: 'postgres:15.3'
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: 'user'
|
POSTGRES_USER: 'user'
|
||||||
POSTGRES_PASSWORD: 'password'
|
POSTGRES_PASSWORD: 'password'
|
||||||
@ -21,10 +21,5 @@ services:
|
|||||||
- 'postgres-data:/var/lib/postgresql/data'
|
- 'postgres-data:/var/lib/postgresql/data'
|
||||||
restart: 'unless-stopped'
|
restart: 'unless-stopped'
|
||||||
|
|
||||||
thream-maildev:
|
|
||||||
image: 'maildev/maildev:1.1.0'
|
|
||||||
ports:
|
|
||||||
- '1080:80'
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres-data:
|
postgres-data:
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
.vscode
|
.*
|
||||||
.git
|
!.npmrc
|
||||||
.env
|
!.swcrc
|
||||||
build
|
build
|
||||||
coverage
|
coverage
|
||||||
.nyc_output
|
|
||||||
node_modules
|
node_modules
|
||||||
tmp
|
|
||||||
temp
|
|
||||||
|
@ -4,13 +4,9 @@
|
|||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"project": "./tsconfig.json"
|
"project": "./tsconfig.json"
|
||||||
},
|
},
|
||||||
"env": {
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"prettier/prettier": "error",
|
"prettier/prettier": "error",
|
||||||
"import/extensions": ["error", "always"],
|
"import/extensions": ["error", "always"],
|
||||||
"unicorn/prevent-abbreviations": "error",
|
"unicorn/prevent-abbreviations": "error"
|
||||||
"unicorn/prefer-node-protocol": "error"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,6 +1,6 @@
|
|||||||
<!-- Please first discuss the change you wish to make via issue before making a change. It might avoid a waste of your time. -->
|
<!-- Please first discuss the change you wish to make via issue before making a change. It might avoid a waste of your time. -->
|
||||||
|
|
||||||
## What changes this PR introduce?
|
# What changes this PR introduce?
|
||||||
|
|
||||||
## List any relevant issue numbers
|
## List any relevant issue numbers
|
||||||
|
|
||||||
|
4
.github/workflows/analyze.yml
vendored
4
.github/workflows/analyze.yml
vendored
@ -16,10 +16,10 @@ jobs:
|
|||||||
language: ['javascript']
|
language: ['javascript']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.0.0'
|
- uses: 'actions/checkout@v3.5.2'
|
||||||
|
|
||||||
- name: 'Initialize CodeQL'
|
- name: 'Initialize CodeQL'
|
||||||
uses: 'github/codeql-action/init@v1'
|
uses: 'github/codeql-action/init@v2'
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
|
|
||||||
|
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@ -10,16 +10,18 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: 'ubuntu-latest'
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.0.0'
|
- uses: 'actions/checkout@v3.5.2'
|
||||||
|
|
||||||
- name: 'Use Node.js'
|
- name: 'Setup Node.js'
|
||||||
uses: 'actions/setup-node@v3.0.0'
|
uses: 'actions/setup-node@v3.6.0'
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: '18.x'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: 'Install'
|
- name: 'Install dependencies'
|
||||||
run: 'npm install'
|
run: 'npm clean-install'
|
||||||
|
|
||||||
- name: 'Build'
|
- name: 'Build'
|
||||||
run: 'npm run build'
|
run: 'npm run build'
|
||||||
|
|
||||||
|
- run: 'npm run build:typescript'
|
||||||
|
21
.github/workflows/lint.yml
vendored
21
.github/workflows/lint.yml
vendored
@ -10,16 +10,16 @@ jobs:
|
|||||||
lint:
|
lint:
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: 'ubuntu-latest'
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.0.0'
|
- uses: 'actions/checkout@v3.5.2'
|
||||||
|
|
||||||
- name: 'Use Node.js'
|
- name: 'Setup Node.js'
|
||||||
uses: 'actions/setup-node@v3.0.0'
|
uses: 'actions/setup-node@v3.6.0'
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: '18.x'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: 'Install'
|
- name: 'Install dependencies'
|
||||||
run: 'npm install'
|
run: 'npm clean-install'
|
||||||
|
|
||||||
- name: 'lint:commit'
|
- name: 'lint:commit'
|
||||||
run: 'npm run lint:commit -- --to "${{ github.sha }}"'
|
run: 'npm run lint:commit -- --to "${{ github.sha }}"'
|
||||||
@ -30,8 +30,8 @@ jobs:
|
|||||||
- name: 'lint:markdown'
|
- name: 'lint:markdown'
|
||||||
run: 'npm run lint:markdown'
|
run: 'npm run lint:markdown'
|
||||||
|
|
||||||
- name: 'lint:typescript'
|
- name: 'lint:eslint'
|
||||||
run: 'npm run lint:typescript'
|
run: 'npm run lint:eslint'
|
||||||
|
|
||||||
- name: 'lint:prettier'
|
- name: 'lint:prettier'
|
||||||
run: 'npm run lint:prettier'
|
run: 'npm run lint:prettier'
|
||||||
@ -41,10 +41,5 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.github_token }}
|
github_token: ${{ secrets.github_token }}
|
||||||
|
|
||||||
- name: 'lint:docker'
|
|
||||||
uses: 'hadolint/hadolint-action@v1.6.0'
|
|
||||||
with:
|
|
||||||
dockerfile: './Dockerfile'
|
|
||||||
|
|
||||||
- name: 'prisma:validate'
|
- name: 'prisma:validate'
|
||||||
run: 'cp .env.example .env && npm run prisma:validate'
|
run: 'cp .env.example .env && npm run prisma:validate'
|
||||||
|
22
.github/workflows/release.yml
vendored
22
.github/workflows/release.yml
vendored
@ -8,30 +8,32 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: 'ubuntu-latest'
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.0.0'
|
- uses: 'actions/checkout@v3.5.2'
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: 'Import GPG key'
|
- name: 'Import GPG key'
|
||||||
uses: 'crazy-max/ghaction-import-gpg@v3.2.0'
|
uses: 'crazy-max/ghaction-import-gpg@v5.3.0'
|
||||||
with:
|
with:
|
||||||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
git-user-signingkey: true
|
git_user_signingkey: true
|
||||||
git-commit-gpgsign: true
|
git_commit_gpgsign: true
|
||||||
|
|
||||||
- name: 'Use Node.js'
|
- name: 'Setup Node.js'
|
||||||
uses: 'actions/setup-node@v3.0.0'
|
uses: 'actions/setup-node@v3.6.0'
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: '18.x'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: 'Install'
|
- name: 'Install dependencies'
|
||||||
run: 'npm install'
|
run: 'npm clean-install'
|
||||||
|
|
||||||
- name: 'Build'
|
- name: 'Build'
|
||||||
run: 'npm run build'
|
run: 'npm run build'
|
||||||
|
|
||||||
|
- run: 'npm run build:typescript'
|
||||||
|
|
||||||
- name: 'Release'
|
- name: 'Release'
|
||||||
run: 'npm run release'
|
run: 'npm run release'
|
||||||
env:
|
env:
|
||||||
|
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@ -10,16 +10,16 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: 'ubuntu-latest'
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.0.0'
|
- uses: 'actions/checkout@v3.5.2'
|
||||||
|
|
||||||
- name: 'Use Node.js'
|
- name: 'Setup Node.js'
|
||||||
uses: 'actions/setup-node@v3.0.0'
|
uses: 'actions/setup-node@v3.6.0'
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: '18.x'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: 'Install'
|
- name: 'Install dependencies'
|
||||||
run: 'npm install'
|
run: 'npm clean-install'
|
||||||
|
|
||||||
- name: 'Build'
|
- name: 'Build'
|
||||||
run: 'npm run build'
|
run: 'npm run build'
|
||||||
|
@ -3,3 +3,4 @@
|
|||||||
|
|
||||||
npm run lint:staged
|
npm run lint:staged
|
||||||
npm run build
|
npm run build
|
||||||
|
npm run build:typescript
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
|
"extends": "markdownlint/style/prettier",
|
||||||
|
"relative-links": true,
|
||||||
"default": true,
|
"default": true,
|
||||||
"MD013": false,
|
"MD033": false
|
||||||
"MD033": false,
|
|
||||||
"MD041": false
|
|
||||||
},
|
},
|
||||||
"globs": ["**/*.{md,mdx}"],
|
"globs": ["**/*.{md,mdx}"],
|
||||||
"ignores": ["**/node_modules"]
|
"ignores": ["**/node_modules"],
|
||||||
|
"customRules": ["markdownlint-rule-relative-links"]
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ representative at an online or offline event.
|
|||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported to the community leaders responsible for enforcement at
|
reported to the community leaders responsible for enforcement at
|
||||||
contact@divlo.fr.
|
<contact@divlo.fr>.
|
||||||
All complaints will be reviewed and investigated promptly and fairly.
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
All community leaders are obligated to respect the privacy and security of the
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
@ -29,31 +29,7 @@ If you're adding new features to **Thream/api**, please include tests.
|
|||||||
|
|
||||||
## Commits
|
## Commits
|
||||||
|
|
||||||
The commit message guidelines respect
|
The commit message guidelines adheres to [Conventional Commits](https://www.conventionalcommits.org/) and [Semantic Versioning](https://semver.org/) for releases.
|
||||||
[@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional)
|
|
||||||
and [Semantic Versioning](https://semver.org/) for releases.
|
|
||||||
|
|
||||||
### Types
|
|
||||||
|
|
||||||
Types define which kind of changes you made to the project.
|
|
||||||
|
|
||||||
| Types | Description |
|
|
||||||
| -------- | ------------------------------------------------------------------------------------------------------------ |
|
|
||||||
| feat | A new feature. |
|
|
||||||
| fix | A bug fix. |
|
|
||||||
| docs | Documentation only changes. |
|
|
||||||
| style | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc). |
|
|
||||||
| refactor | A code change that neither fixes a bug nor adds a feature. |
|
|
||||||
| perf | A code change that improves performance. |
|
|
||||||
| test | Adding missing tests or correcting existing tests. |
|
|
||||||
| build | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm). |
|
|
||||||
| ci | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs). |
|
|
||||||
| chore | Other changes that don't modify src or test files. |
|
|
||||||
| revert | Reverts a previous commit. |
|
|
||||||
|
|
||||||
### Scopes
|
|
||||||
|
|
||||||
Scopes define what part of the code changed.
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
FROM node:16.17.0 AS dependencies
|
FROM node:18.16.0 AS dependencies
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY ./package*.json ./
|
COPY ./package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
FROM node:16.17.0 AS builder
|
FROM node:18.16.0 AS builder
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY --from=dependencies /usr/src/app/node_modules ./node_modules
|
COPY --from=dependencies /usr/src/app/node_modules ./node_modules
|
||||||
COPY ./ ./
|
COPY ./ ./
|
||||||
RUN npm run prisma:generate && npm run build
|
RUN npm run prisma:generate && npm run build
|
||||||
|
|
||||||
FROM node:16.17.0 AS runner
|
FROM node:18.16.0 AS runner
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
Thream's Application Programming Interface (API) to stay close with your friends and communities.
|
Thream's Application Programming Interface (API) to stay close with your friends and communities.
|
||||||
|
|
||||||
It uses [Thream/file-uploads-api](https://github.com/Thream/file-uploads-api) [v1.1.0](https://github.com/Thream/file-uploads-api/releases/tag/v1.1.0).
|
It uses [Thream/file-uploads-api](https://github.com/Thream/file-uploads-api) [v1.1.4](https://github.com/Thream/file-uploads-api/releases/tag/v1.1.4).
|
||||||
|
|
||||||
## ⚙️ Getting Started
|
## ⚙️ Getting Started
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ cp .env.example .env
|
|||||||
|
|
||||||
# Install
|
# Install
|
||||||
npm install
|
npm install
|
||||||
|
npm run prisma:generate
|
||||||
```
|
```
|
||||||
|
|
||||||
You will need to configure the environment variables by creating an `.env` file at
|
You will need to configure the environment variables by creating an `.env` file at
|
||||||
|
21431
package-lock.json
generated
21431
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
131
package.json
131
package.json
@ -1,104 +1,113 @@
|
|||||||
{
|
{
|
||||||
"name": "@thream/api",
|
"name": "@thream/api",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"description": "Thream's application programming interface to stay close with your friends and communities.",
|
"description": "Thream's application programming interface to stay close with your friends and communities.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"imports": {
|
||||||
"type": "git",
|
"#src/*": "./build/*"
|
||||||
"url": "https://github.com/Thream/api"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.0.0",
|
"node": ">=16.0.0",
|
||||||
"npm": ">=8.0.0"
|
"npm": ">=8.0.0"
|
||||||
},
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Thream/api"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rimraf ./build && swc ./src --out-dir ./build && tsc",
|
"build": "rimraf ./build && swc ./src --out-dir ./build",
|
||||||
"build:dev": "swc ./src --out-dir ./build --watch",
|
"build:typescript": "tsc",
|
||||||
"start": "node build/index.js",
|
"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\"",
|
"dev:build": "swc ./src --out-dir ./build --watch",
|
||||||
|
"dev": "concurrently --kill-others --names \"TypeScript,Node,Maildev,Prisma Studio\" \"npm run dev:build\" \"cross-env NODE_ENV=development nodemon build/index.js\" \"npm run maildev\" \"npm run prisma:studio\"",
|
||||||
|
"maildev": "maildev",
|
||||||
"generate": "plop",
|
"generate": "plop",
|
||||||
"generate:jwt-secret": "node ./build/scripts/generate-jwt-secret.js",
|
"generate:jwt-secret": "node ./build/scripts/generate-jwt-secret.js",
|
||||||
"lint:commit": "commitlint",
|
"lint:commit": "commitlint",
|
||||||
"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:eslint": "eslint \".\" --ignore-path \".gitignore\"",
|
||||||
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
|
"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",
|
||||||
"prisma:generate": "prisma generate",
|
"prisma:generate": "prisma generate",
|
||||||
"prisma:studio": "prisma studio",
|
"prisma:studio": "prisma studio --browser=none",
|
||||||
"prisma:migrate:dev": "prisma migrate dev",
|
"prisma:migrate:dev": "prisma migrate dev",
|
||||||
"prisma:migrate:deploy": "prisma migrate deploy",
|
"prisma:migrate:deploy": "prisma migrate deploy",
|
||||||
"release": "semantic-release",
|
"release": "semantic-release",
|
||||||
"postinstall": "husky install"
|
"postinstall": "husky install"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/cors": "8.1.0",
|
"@fastify/cors": "8.2.1",
|
||||||
"@fastify/helmet": "10.0.1",
|
"@fastify/helmet": "10.1.1",
|
||||||
"@fastify/multipart": "7.2.0",
|
"@fastify/multipart": "7.6.0",
|
||||||
"@fastify/rate-limit": "7.4.0",
|
"@fastify/rate-limit": "8.0.0",
|
||||||
"@fastify/sensible": "5.1.1",
|
"@fastify/sensible": "5.2.0",
|
||||||
"@fastify/swagger": "7.6.1",
|
"@fastify/swagger": "8.3.1",
|
||||||
"@prisma/client": "4.4.0",
|
"@fastify/swagger-ui": "1.8.1",
|
||||||
"@sinclair/typebox": "0.24.44",
|
"@prisma/client": "4.14.0",
|
||||||
"@thream/socketio-jwt": "3.0.1",
|
"@sinclair/typebox": "0.28.10",
|
||||||
"axios": "0.26.1",
|
"@thream/socketio-jwt": "3.1.0",
|
||||||
|
"axios": "1.4.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"dotenv": "16.0.3",
|
"dotenv": "16.0.3",
|
||||||
"ejs": "3.1.8",
|
"ejs": "3.1.9",
|
||||||
"fastify": "4.7.0",
|
"fastify": "4.17.0",
|
||||||
"fastify-plugin": "4.2.1",
|
"fastify-plugin": "4.5.0",
|
||||||
"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": "9.0.0",
|
||||||
"ms": "2.1.3",
|
"ms": "2.1.3",
|
||||||
"nodemailer": "6.8.0",
|
"nodemailer": "6.9.2",
|
||||||
"read-pkg": "7.1.0",
|
"read-pkg": "8.0.0",
|
||||||
"socket.io": "4.5.2"
|
"socket.io": "4.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "17.1.2",
|
"@commitlint/cli": "17.6.3",
|
||||||
"@commitlint/config-conventional": "17.1.0",
|
"@commitlint/config-conventional": "17.6.3",
|
||||||
"@saithodev/semantic-release-backmerge": "2.1.2",
|
"@saithodev/semantic-release-backmerge": "3.2.0",
|
||||||
"@semantic-release/git": "10.0.1",
|
"@semantic-release/git": "10.0.1",
|
||||||
"@swc/cli": "0.1.57",
|
"@swc/cli": "0.1.62",
|
||||||
"@swc/core": "1.3.4",
|
"@swc/core": "1.3.57",
|
||||||
|
"@tsconfig/strictest": "2.0.1",
|
||||||
"@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.2",
|
||||||
"@types/http-errors": "1.8.2",
|
"@types/http-errors": "2.0.1",
|
||||||
"@types/jsonwebtoken": "8.5.9",
|
"@types/jsonwebtoken": "9.0.2",
|
||||||
"@types/ms": "0.7.31",
|
"@types/ms": "0.7.31",
|
||||||
"@types/node": "18.8.1",
|
"@types/node": "20.1.4",
|
||||||
"@types/nodemailer": "6.4.6",
|
"@types/nodemailer": "6.4.7",
|
||||||
"@types/sinon": "10.0.13",
|
"@types/sinon": "10.0.14",
|
||||||
"@types/tap": "15.0.7",
|
"@types/tap": "15.0.8",
|
||||||
"@typescript-eslint/eslint-plugin": "5.39.0",
|
"@typescript-eslint/eslint-plugin": "5.59.5",
|
||||||
"@typescript-eslint/parser": "5.39.0",
|
"@typescript-eslint/parser": "5.59.5",
|
||||||
"c8": "7.12.0",
|
"c8": "7.13.0",
|
||||||
"concurrently": "7.4.0",
|
"concurrently": "8.0.1",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"editorconfig-checker": "4.0.2",
|
"editorconfig-checker": "5.0.1",
|
||||||
"eslint": "8.24.0",
|
"eslint": "8.40.0",
|
||||||
"eslint-config-conventions": "5.0.0",
|
"eslint-config-conventions": "9.0.0",
|
||||||
"eslint-config-prettier": "8.5.0",
|
"eslint-config-prettier": "8.8.0",
|
||||||
"eslint-plugin-import": "2.26.0",
|
"eslint-plugin-import": "2.27.5",
|
||||||
"eslint-plugin-prettier": "4.2.1",
|
"eslint-plugin-prettier": "4.2.1",
|
||||||
"eslint-plugin-promise": "6.0.1",
|
"eslint-plugin-promise": "6.1.1",
|
||||||
"eslint-plugin-unicorn": "44.0.0",
|
"eslint-plugin-unicorn": "47.0.0",
|
||||||
"husky": "8.0.1",
|
"husky": "8.0.3",
|
||||||
"lint-staged": "13.0.3",
|
"lint-staged": "13.2.2",
|
||||||
"markdownlint-cli2": "0.5.1",
|
"maildev": "2.0.5",
|
||||||
"nodemon": "2.0.20",
|
"markdownlint-cli2": "0.7.1",
|
||||||
"plop": "3.1.1",
|
"markdownlint-rule-relative-links": "1.2.0",
|
||||||
"prettier": "2.7.1",
|
"nodemon": "2.0.22",
|
||||||
"prisma": "4.4.0",
|
"plop": "3.1.2",
|
||||||
"rimraf": "3.0.2",
|
"prettier": "2.8.8",
|
||||||
"semantic-release": "19.0.5",
|
"prisma": "4.14.0",
|
||||||
"sinon": "14.0.1",
|
"rimraf": "5.0.0",
|
||||||
"tap": "16.3.0",
|
"semantic-release": "21.0.2",
|
||||||
"typescript": "4.8.4"
|
"sinon": "15.0.4",
|
||||||
|
"tap": "16.3.4",
|
||||||
|
"typescript": "5.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,19 @@ import dotenv from 'dotenv'
|
|||||||
import fastify from 'fastify'
|
import fastify from 'fastify'
|
||||||
import fastifyCors from '@fastify/cors'
|
import fastifyCors from '@fastify/cors'
|
||||||
import fastifySwagger from '@fastify/swagger'
|
import fastifySwagger from '@fastify/swagger'
|
||||||
|
import fastifySwaggerUI from '@fastify/swagger-ui'
|
||||||
import fastifyHelmet from '@fastify/helmet'
|
import fastifyHelmet from '@fastify/helmet'
|
||||||
import fastifyRateLimit from '@fastify/rate-limit'
|
import fastifyRateLimit from '@fastify/rate-limit'
|
||||||
import fastifySensible from '@fastify/sensible'
|
import fastifySensible from '@fastify/sensible'
|
||||||
|
import { readPackage } from 'read-pkg'
|
||||||
|
|
||||||
import { services } from './services/index.js'
|
import { services } from './services/index.js'
|
||||||
import { swaggerOptions } from './tools/configurations/swaggerOptions.js'
|
|
||||||
import fastifySocketIo from './tools/plugins/socket-io.js'
|
import fastifySocketIo from './tools/plugins/socket-io.js'
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
const packageJSON = await readPackage()
|
||||||
export const application = fastify({
|
export const application = fastify({
|
||||||
logger: process.env.NODE_ENV === 'development',
|
logger: process.env['NODE_ENV'] === 'development',
|
||||||
ajv: {
|
ajv: {
|
||||||
customOptions: {
|
customOptions: {
|
||||||
strict: 'log',
|
strict: 'log',
|
||||||
@ -39,5 +41,35 @@ await application.register(fastifyRateLimit, {
|
|||||||
max: 200,
|
max: 200,
|
||||||
timeWindow: '1 minute'
|
timeWindow: '1 minute'
|
||||||
})
|
})
|
||||||
await application.register(fastifySwagger, swaggerOptions)
|
await application.register(fastifySwagger, {
|
||||||
|
openapi: {
|
||||||
|
info: {
|
||||||
|
title: packageJSON.name,
|
||||||
|
description: packageJSON.description,
|
||||||
|
version: packageJSON.version
|
||||||
|
},
|
||||||
|
tags: [
|
||||||
|
{ name: 'users' },
|
||||||
|
{ name: 'oauth2' },
|
||||||
|
{ name: 'guilds' },
|
||||||
|
{ name: 'channels' },
|
||||||
|
{ name: 'messages' },
|
||||||
|
{ name: 'members' }
|
||||||
|
],
|
||||||
|
components: {
|
||||||
|
securitySchemes: {
|
||||||
|
bearerAuth: {
|
||||||
|
type: 'http',
|
||||||
|
scheme: 'bearer',
|
||||||
|
bearerFormat: 'JWT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hideUntagged: true
|
||||||
|
})
|
||||||
|
await application.register(fastifySwaggerUI, {
|
||||||
|
routePrefix: '/documentation',
|
||||||
|
staticCSP: true
|
||||||
|
})
|
||||||
await application.register(services)
|
await application.register(services)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { application } from './application.js'
|
import { application } from './application.js'
|
||||||
import { HOST, PORT } from './tools/configurations/index.js'
|
import { HOST, PORT } from '#src/tools/configurations.js'
|
||||||
|
|
||||||
const address = await application.listen({
|
const address = await application.listen({
|
||||||
port: PORT,
|
port: PORT,
|
||||||
|
@ -12,8 +12,8 @@ export const providersTypebox = providers.map((provider) => {
|
|||||||
return Type.Literal(provider)
|
return Type.Literal(provider)
|
||||||
})
|
})
|
||||||
|
|
||||||
export type ProviderOAuth = typeof providers[number]
|
export type ProviderOAuth = (typeof providers)[number]
|
||||||
export type AuthenticationStrategy = typeof strategies[number]
|
export type AuthenticationStrategy = (typeof strategies)[number]
|
||||||
|
|
||||||
export const oauthSchema = {
|
export const oauthSchema = {
|
||||||
id,
|
id,
|
||||||
|
@ -54,7 +54,7 @@ export const getConfirmEmail: FastifyPluginAsync = async (fastify) => {
|
|||||||
reply.statusCode = 200
|
reply.statusCode = 200
|
||||||
return 'Success, your email has been confirmed, you can now signin!'
|
return 'Success, your email has been confirmed, you can now signin!'
|
||||||
}
|
}
|
||||||
await reply.redirect(redirectURI)
|
return await reply.redirect(redirectURI)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import { fastifyErrors } from '../../../models/utils.js'
|
|||||||
import authenticateUser from '../../../tools/plugins/authenticateUser.js'
|
import authenticateUser from '../../../tools/plugins/authenticateUser.js'
|
||||||
import { userCurrentSchema, userSchema } from '../../../models/User.js'
|
import { userCurrentSchema, userSchema } from '../../../models/User.js'
|
||||||
import { sendEmail } from '../../../tools/email/sendEmail.js'
|
import { sendEmail } from '../../../tools/email/sendEmail.js'
|
||||||
import { API_URL } from '../../../tools/configurations/index.js'
|
import { API_URL } from '../../../tools/configurations.js'
|
||||||
import type { Language, Theme } from '../../../models/UserSettings.js'
|
import type { Language, Theme } from '../../../models/UserSettings.js'
|
||||||
import { parseStringNullish } from '../../../tools/utils/parseStringNullish.js'
|
import { parseStringNullish } from '../../../tools/utils/parseStringNullish.js'
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ import { OAuthStrategy } from '../../../../../tools/utils/OAuthStrategy.js'
|
|||||||
export const DISCORD_PROVIDER = 'Discord'
|
export const DISCORD_PROVIDER = 'Discord'
|
||||||
export const DISCORD_BASE_URL = 'https://discord.com/api/v10'
|
export const DISCORD_BASE_URL = 'https://discord.com/api/v10'
|
||||||
export const DISCORD_CLIENT_ID =
|
export const DISCORD_CLIENT_ID =
|
||||||
process.env.DISCORD_CLIENT_ID ?? 'DISCORD_CLIENT_ID'
|
process.env['DISCORD_CLIENT_ID'] ?? 'DISCORD_CLIENT_ID'
|
||||||
export const DISCORD_CLIENT_SECRET =
|
export const DISCORD_CLIENT_SECRET =
|
||||||
process.env.DISCORD_CLIENT_SECRET ?? 'DISCORD_CLIENT_SECRET'
|
process.env['DISCORD_CLIENT_SECRET'] ?? 'DISCORD_CLIENT_SECRET'
|
||||||
export const discordStrategy = new OAuthStrategy(DISCORD_PROVIDER)
|
export const discordStrategy = new OAuthStrategy(DISCORD_PROVIDER)
|
||||||
|
|
||||||
export interface DiscordUser {
|
export interface DiscordUser {
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { DISCORD_BASE_URL, DISCORD_CLIENT_ID } from '../__utils__/utils.js'
|
import { DISCORD_BASE_URL, DISCORD_CLIENT_ID } from '../__utils__/utils.js'
|
||||||
import authenticateUser from '../../../../../tools/plugins/authenticateUser.js'
|
import authenticateUser from '../../../../../tools/plugins/authenticateUser.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { discordStrategy, getDiscordUserData } from '../__utils__/utils.js'
|
import { discordStrategy, getDiscordUserData } from '../__utils__/utils.js'
|
||||||
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { discordStrategy, getDiscordUserData } from '../__utils__/utils.js'
|
import { discordStrategy, getDiscordUserData } from '../__utils__/utils.js'
|
||||||
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { DISCORD_BASE_URL, DISCORD_CLIENT_ID } from '../__utils__/utils.js'
|
import { DISCORD_BASE_URL, DISCORD_CLIENT_ID } from '../__utils__/utils.js'
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ export const GITHUB_PROVIDER = 'GitHub'
|
|||||||
export const GITHUB_BASE_URL = 'https://github.com'
|
export const GITHUB_BASE_URL = 'https://github.com'
|
||||||
export const GITHUB_API_BASE_URL = 'https://api.github.com'
|
export const GITHUB_API_BASE_URL = 'https://api.github.com'
|
||||||
export const GITHUB_CLIENT_ID =
|
export const GITHUB_CLIENT_ID =
|
||||||
process.env.GITHUB_CLIENT_ID ?? 'GITHUB_CLIENT_ID'
|
process.env['GITHUB_CLIENT_ID'] ?? 'GITHUB_CLIENT_ID'
|
||||||
export const GITHUB_CLIENT_SECRET =
|
export const GITHUB_CLIENT_SECRET =
|
||||||
process.env.GITHUB_CLIENT_SECRET ?? 'GITHUB_CLIENT_SECRET'
|
process.env['GITHUB_CLIENT_SECRET'] ?? 'GITHUB_CLIENT_SECRET'
|
||||||
export const githubStrategy = new OAuthStrategy(GITHUB_PROVIDER)
|
export const githubStrategy = new OAuthStrategy(GITHUB_PROVIDER)
|
||||||
|
|
||||||
export interface GitHubUser {
|
export interface GitHubUser {
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { GITHUB_BASE_URL, GITHUB_CLIENT_ID } from '../__utils__/utils.js'
|
import { GITHUB_BASE_URL, GITHUB_CLIENT_ID } from '../__utils__/utils.js'
|
||||||
import authenticateUser from '../../../../../tools/plugins/authenticateUser.js'
|
import authenticateUser from '../../../../../tools/plugins/authenticateUser.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { githubStrategy, getGitHubUserData } from '../__utils__/utils.js'
|
import { githubStrategy, getGitHubUserData } from '../__utils__/utils.js'
|
||||||
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { githubStrategy, getGitHubUserData } from '../__utils__/utils.js'
|
import { githubStrategy, getGitHubUserData } from '../__utils__/utils.js'
|
||||||
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { GITHUB_BASE_URL, GITHUB_CLIENT_ID } from '../__utils__/utils.js'
|
import { GITHUB_BASE_URL, GITHUB_CLIENT_ID } from '../__utils__/utils.js'
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ export const GOOGLE_OAUTH2_TOKEN = 'https://oauth2.googleapis.com/token'
|
|||||||
export const GOOGLE_USERINFO =
|
export const GOOGLE_USERINFO =
|
||||||
'https://www.googleapis.com/oauth2/v1/userinfo?alt=json'
|
'https://www.googleapis.com/oauth2/v1/userinfo?alt=json'
|
||||||
export const GOOGLE_CLIENT_ID =
|
export const GOOGLE_CLIENT_ID =
|
||||||
process.env.GOOGLE_CLIENT_ID ?? 'GOOGLE_CLIENT_ID'
|
process.env['GOOGLE_CLIENT_ID'] ?? 'GOOGLE_CLIENT_ID'
|
||||||
export const GOOGLE_CLIENT_SECRET =
|
export const GOOGLE_CLIENT_SECRET =
|
||||||
process.env.GOOGLE_CLIENT_SECRET ?? 'GOOGLE_CLIENT_SECRET'
|
process.env['GOOGLE_CLIENT_SECRET'] ?? 'GOOGLE_CLIENT_SECRET'
|
||||||
export const googleStrategy = new OAuthStrategy(GOOGLE_PROVIDER)
|
export const googleStrategy = new OAuthStrategy(GOOGLE_PROVIDER)
|
||||||
|
|
||||||
export interface GoogleUser {
|
export interface GoogleUser {
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { GOOGLE_BASE_URL, GOOGLE_CLIENT_ID } from '../__utils__/utils.js'
|
import { GOOGLE_BASE_URL, GOOGLE_CLIENT_ID } from '../__utils__/utils.js'
|
||||||
import authenticateUser from '../../../../../tools/plugins/authenticateUser.js'
|
import authenticateUser from '../../../../../tools/plugins/authenticateUser.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { googleStrategy, getGoogleUserData } from '../__utils__/utils.js'
|
import { googleStrategy, getGoogleUserData } from '../__utils__/utils.js'
|
||||||
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { googleStrategy, getGoogleUserData } from '../__utils__/utils.js'
|
import { googleStrategy, getGoogleUserData } from '../__utils__/utils.js'
|
||||||
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js'
|
||||||
|
@ -2,7 +2,7 @@ import type { Static } from '@sinclair/typebox'
|
|||||||
import { Type } from '@sinclair/typebox'
|
import { Type } from '@sinclair/typebox'
|
||||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||||
|
|
||||||
import { API_URL } from '../../../../../tools/configurations/index.js'
|
import { API_URL } from '../../../../../tools/configurations.js'
|
||||||
import { fastifyErrors } from '../../../../../models/utils.js'
|
import { fastifyErrors } from '../../../../../models/utils.js'
|
||||||
import { GOOGLE_BASE_URL, GOOGLE_CLIENT_ID } from '../__utils__/utils.js'
|
import { GOOGLE_BASE_URL, GOOGLE_CLIENT_ID } from '../__utils__/utils.js'
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
expiresIn
|
expiresIn
|
||||||
} from '../../../tools/utils/jwtToken.js'
|
} from '../../../tools/utils/jwtToken.js'
|
||||||
import type { UserRefreshJWT } from '../../../models/User.js'
|
import type { UserRefreshJWT } from '../../../models/User.js'
|
||||||
import { JWT_REFRESH_SECRET } from '../../../tools/configurations/index.js'
|
import { JWT_REFRESH_SECRET } from '../../../tools/configurations.js'
|
||||||
|
|
||||||
const bodyPostRefreshTokenSchema = Type.Object({
|
const bodyPostRefreshTokenSchema = Type.Object({
|
||||||
refreshToken: jwtSchema.refreshToken
|
refreshToken: jwtSchema.refreshToken
|
||||||
|
@ -5,7 +5,7 @@ import jwt from 'jsonwebtoken'
|
|||||||
|
|
||||||
import prisma from '../../../tools/database/prisma.js'
|
import prisma from '../../../tools/database/prisma.js'
|
||||||
import { fastifyErrors } from '../../../models/utils.js'
|
import { fastifyErrors } from '../../../models/utils.js'
|
||||||
import { JWT_REFRESH_SECRET } from '../../../tools/configurations/index.js'
|
import { JWT_REFRESH_SECRET } from '../../../tools/configurations.js'
|
||||||
import type { UserRefreshJWT } from '../../../models/User.js'
|
import type { UserRefreshJWT } from '../../../models/User.js'
|
||||||
import { jwtSchema } from '../../../tools/utils/jwtToken.js'
|
import { jwtSchema } from '../../../tools/utils/jwtToken.js'
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import { fastifyErrors } from '../../../models/utils.js'
|
|||||||
import type { BodyUserSchemaType } from '../../../models/User.js'
|
import type { BodyUserSchemaType } from '../../../models/User.js'
|
||||||
import { bodyUserSchema, userPublicSchema } from '../../../models/User.js'
|
import { bodyUserSchema, userPublicSchema } from '../../../models/User.js'
|
||||||
import { sendEmail } from '../../../tools/email/sendEmail.js'
|
import { sendEmail } from '../../../tools/email/sendEmail.js'
|
||||||
import { API_URL } from '../../../tools/configurations/index.js'
|
import { API_URL } from '../../../tools/configurations.js'
|
||||||
|
|
||||||
const queryPostSignupSchema = Type.Object({
|
const queryPostSignupSchema = Type.Object({
|
||||||
redirectURI: Type.Optional(Type.String({ format: 'uri-reference' }))
|
redirectURI: Type.Optional(Type.String({ format: 'uri-reference' }))
|
||||||
|
25
src/tools/configurations.ts
Normal file
25
src/tools/configurations.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { URL } from 'node:url'
|
||||||
|
|
||||||
|
import dotenv from 'dotenv'
|
||||||
|
|
||||||
|
dotenv.config()
|
||||||
|
|
||||||
|
export const PORT = parseInt(process.env['PORT'] ?? '8080', 10)
|
||||||
|
export const HOST = process.env['HOST'] ?? '0.0.0.0'
|
||||||
|
export const API_URL = process.env['API_URL'] ?? `http://${HOST}:${PORT}`
|
||||||
|
export const FILE_UPLOADS_API_URL =
|
||||||
|
process.env['FILE_UPLOADS_API_URL'] ?? 'http://localhost:8000'
|
||||||
|
export const FILE_UPLOADS_API_KEY =
|
||||||
|
process.env['FILE_UPLOADS_API_KEY'] ?? 'apiKeySecret'
|
||||||
|
export const JWT_ACCESS_SECRET =
|
||||||
|
process.env['JWT_ACCESS_SECRET'] ?? 'accessTokenSecret'
|
||||||
|
export const JWT_REFRESH_SECRET =
|
||||||
|
process.env['JWT_REFRESH_SECRET'] ?? 'refreshTokenSecret'
|
||||||
|
export const JWT_ACCESS_EXPIRES_IN =
|
||||||
|
process.env['JWT_ACCESS_EXPIRES_IN'] ?? '15 minutes'
|
||||||
|
|
||||||
|
export const SRC_URL = new URL('../', import.meta.url)
|
||||||
|
export const ROOT_URL = new URL('../', SRC_URL)
|
||||||
|
export const EMAIL_URL = new URL('./email/', ROOT_URL)
|
||||||
|
export const EMAIL_TEMPLATE_URL = new URL('./email-template.ejs', EMAIL_URL)
|
||||||
|
export const EMAIL_LOCALES_URL = new URL('./locales/', EMAIL_URL)
|
@ -1,25 +0,0 @@
|
|||||||
import { URL } from 'node:url'
|
|
||||||
|
|
||||||
import dotenv from 'dotenv'
|
|
||||||
|
|
||||||
dotenv.config()
|
|
||||||
|
|
||||||
export const PORT = parseInt(process.env.PORT ?? '8080', 10)
|
|
||||||
export const HOST = process.env.HOST ?? '0.0.0.0'
|
|
||||||
export const API_URL = process.env.API_URL ?? `http://${HOST}:${PORT}`
|
|
||||||
export const FILE_UPLOADS_API_URL =
|
|
||||||
process.env.FILE_UPLOADS_API_URL ?? 'http://localhost:8000'
|
|
||||||
export const FILE_UPLOADS_API_KEY =
|
|
||||||
process.env.FILE_UPLOADS_API_KEY ?? 'apiKeySecret'
|
|
||||||
export const JWT_ACCESS_SECRET =
|
|
||||||
process.env.JWT_ACCESS_SECRET ?? 'accessTokenSecret'
|
|
||||||
export const JWT_REFRESH_SECRET =
|
|
||||||
process.env.JWT_REFRESH_SECRET ?? 'refreshTokenSecret'
|
|
||||||
export const JWT_ACCESS_EXPIRES_IN =
|
|
||||||
process.env.JWT_ACCESS_EXPIRES_IN ?? '15 minutes'
|
|
||||||
|
|
||||||
export const SRC_URL = new URL('../../', import.meta.url)
|
|
||||||
export const ROOT_URL = new URL('../', SRC_URL)
|
|
||||||
export const EMAIL_URL = new URL('./email/', ROOT_URL)
|
|
||||||
export const EMAIL_TEMPLATE_URL = new URL('./email-template.ejs', EMAIL_URL)
|
|
||||||
export const EMAIL_LOCALES_URL = new URL('./locales/', EMAIL_URL)
|
|
@ -1,38 +0,0 @@
|
|||||||
import dotenv from 'dotenv'
|
|
||||||
import { readPackage } from 'read-pkg'
|
|
||||||
import type { FastifyDynamicSwaggerOptions } from '@fastify/swagger'
|
|
||||||
|
|
||||||
dotenv.config()
|
|
||||||
|
|
||||||
const packageJSON = await readPackage()
|
|
||||||
|
|
||||||
export const swaggerOptions: FastifyDynamicSwaggerOptions = {
|
|
||||||
routePrefix: '/documentation',
|
|
||||||
openapi: {
|
|
||||||
info: {
|
|
||||||
title: packageJSON.name,
|
|
||||||
description: packageJSON.description,
|
|
||||||
version: packageJSON.version
|
|
||||||
},
|
|
||||||
tags: [
|
|
||||||
{ name: 'users' },
|
|
||||||
{ name: 'oauth2' },
|
|
||||||
{ name: 'guilds' },
|
|
||||||
{ name: 'channels' },
|
|
||||||
{ name: 'messages' },
|
|
||||||
{ name: 'members' }
|
|
||||||
],
|
|
||||||
components: {
|
|
||||||
securitySchemes: {
|
|
||||||
bearerAuth: {
|
|
||||||
type: 'http',
|
|
||||||
scheme: 'bearer',
|
|
||||||
bearerFormat: 'JWT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
exposeRoute: true,
|
|
||||||
staticCSP: true,
|
|
||||||
hideUntagged: true
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ const { PrismaClient } = Prisma
|
|||||||
|
|
||||||
const prisma = new PrismaClient({
|
const prisma = new PrismaClient({
|
||||||
log:
|
log:
|
||||||
process.env.NODE_ENV === 'development'
|
process.env['NODE_ENV'] === 'development'
|
||||||
? ['query', 'info', 'warn', 'error']
|
? ['query', 'info', 'warn', 'error']
|
||||||
: ['error']
|
: ['error']
|
||||||
})
|
})
|
||||||
|
@ -3,17 +3,17 @@ import nodemailer from 'nodemailer'
|
|||||||
import type SMTPTransport from 'nodemailer/lib/smtp-transport/index.js'
|
import type SMTPTransport from 'nodemailer/lib/smtp-transport/index.js'
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
const EMAIL_PORT = parseInt(process.env.EMAIL_PORT ?? '465', 10)
|
const EMAIL_PORT = parseInt(process.env['EMAIL_PORT'] ?? '465', 10)
|
||||||
|
|
||||||
export const EMAIL_INFO: SMTPTransport.Options = {
|
export const EMAIL_INFO: SMTPTransport.Options = {
|
||||||
host: process.env.EMAIL_HOST,
|
host: process.env['EMAIL_HOST'],
|
||||||
port: EMAIL_PORT,
|
port: EMAIL_PORT,
|
||||||
secure: EMAIL_PORT === 465,
|
secure: EMAIL_PORT === 465,
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.EMAIL_USER,
|
user: process.env['EMAIL_USER'],
|
||||||
pass: process.env.EMAIL_PASSWORD
|
pass: process.env['EMAIL_PASSWORD']
|
||||||
},
|
},
|
||||||
ignoreTLS: process.env.NODE_ENV !== 'production'
|
ignoreTLS: process.env['NODE_ENV'] !== 'production'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const emailTransporter = nodemailer.createTransport(EMAIL_INFO)
|
export const emailTransporter = nodemailer.createTransport(EMAIL_INFO)
|
||||||
|
@ -4,10 +4,7 @@ import { URL, fileURLToPath } from 'node:url'
|
|||||||
import ejs from 'ejs'
|
import ejs from 'ejs'
|
||||||
|
|
||||||
import type { Language, Theme } from '../../models/UserSettings.js'
|
import type { Language, Theme } from '../../models/UserSettings.js'
|
||||||
import {
|
import { EMAIL_LOCALES_URL, EMAIL_TEMPLATE_URL } from '../configurations.js'
|
||||||
EMAIL_LOCALES_URL,
|
|
||||||
EMAIL_TEMPLATE_URL
|
|
||||||
} from '../configurations/index.js'
|
|
||||||
import { emailTransporter, EMAIL_INFO } from './emailTransporter.js'
|
import { emailTransporter, EMAIL_INFO } from './emailTransporter.js'
|
||||||
|
|
||||||
interface EmailTranslation {
|
interface EmailTranslation {
|
||||||
|
@ -4,7 +4,7 @@ import jwt from 'jsonwebtoken'
|
|||||||
|
|
||||||
import prisma from '../database/prisma.js'
|
import prisma from '../database/prisma.js'
|
||||||
import type { UserJWT, UserRequest } from '../../models/User.js'
|
import type { UserJWT, UserRequest } from '../../models/User.js'
|
||||||
import { JWT_ACCESS_SECRET } from '../configurations/index.js'
|
import { JWT_ACCESS_SECRET } from '../configurations.js'
|
||||||
|
|
||||||
const { Unauthorized, Forbidden, BadRequest } = httpErrors
|
const { Unauthorized, Forbidden, BadRequest } = httpErrors
|
||||||
|
|
||||||
@ -20,10 +20,10 @@ export const getUserWithBearerToken = async (
|
|||||||
throw new Unauthorized()
|
throw new Unauthorized()
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = tokenSplitted[1]
|
const token = tokenSplitted[1] ?? 'token'
|
||||||
let payload: UserJWT
|
let payload: UserJWT
|
||||||
try {
|
try {
|
||||||
payload = jwt.verify(token, JWT_ACCESS_SECRET) as UserJWT
|
payload = jwt.verify(token, JWT_ACCESS_SECRET) as unknown as UserJWT
|
||||||
} catch {
|
} catch {
|
||||||
throw new Forbidden()
|
throw new Forbidden()
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { Server as SocketIoServer } from 'socket.io'
|
|||||||
import { authorize } from '@thream/socketio-jwt'
|
import { authorize } from '@thream/socketio-jwt'
|
||||||
|
|
||||||
import prisma from '../database/prisma.js'
|
import prisma from '../database/prisma.js'
|
||||||
import { JWT_ACCESS_SECRET } from '../configurations/index.js'
|
import { JWT_ACCESS_SECRET } from '../configurations.js'
|
||||||
|
|
||||||
interface EmitEventOptions {
|
interface EmitEventOptions {
|
||||||
event: string
|
event: string
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
JWT_ACCESS_EXPIRES_IN,
|
JWT_ACCESS_EXPIRES_IN,
|
||||||
JWT_ACCESS_SECRET,
|
JWT_ACCESS_SECRET,
|
||||||
JWT_REFRESH_SECRET
|
JWT_REFRESH_SECRET
|
||||||
} from '../configurations/index.js'
|
} from '../configurations.js'
|
||||||
|
|
||||||
export interface ResponseJWT {
|
export interface ResponseJWT {
|
||||||
accessToken: string
|
accessToken: string
|
||||||
|
@ -8,7 +8,7 @@ import type { SavedMultipartFile } from '@fastify/multipart'
|
|||||||
import {
|
import {
|
||||||
FILE_UPLOADS_API_KEY,
|
FILE_UPLOADS_API_KEY,
|
||||||
FILE_UPLOADS_API_URL
|
FILE_UPLOADS_API_URL
|
||||||
} from '../configurations/index.js'
|
} from '../configurations.js'
|
||||||
|
|
||||||
export const fileUploadAPI = axios.create({
|
export const fileUploadAPI = axios.create({
|
||||||
baseURL: FILE_UPLOADS_API_URL,
|
baseURL: FILE_UPLOADS_API_URL,
|
||||||
@ -48,10 +48,10 @@ export const uploadFile = async (
|
|||||||
`File should be less than ${MAXIMUM_FILE_SIZE}mb.`
|
`File should be less than ${MAXIMUM_FILE_SIZE}mb.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (files.length !== 1) {
|
const file = files[0]
|
||||||
|
if (files.length !== 1 || file == null) {
|
||||||
throw fastify.httpErrors.badRequest('You must upload at most one file.')
|
throw fastify.httpErrors.badRequest('You must upload at most one file.')
|
||||||
}
|
}
|
||||||
const file = files[0]
|
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', fs.createReadStream(file.filepath))
|
formData.append('file', fs.createReadStream(file.filepath))
|
||||||
try {
|
try {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "@tsconfig/strictest/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
@ -6,9 +7,12 @@
|
|||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"outDir": "./build",
|
"outDir": "./build",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"#src/*": ["./src/*"]
|
||||||
|
},
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"strict": true,
|
"exactOptionalPropertyTypes": false,
|
||||||
"skipLibCheck": true,
|
"checkJs": false
|
||||||
"esModuleInterop": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user