Skip to content

Commit 533a028

Browse files
authored
Merge pull request #4 from Libertech-FR/1-define-base-structure
1 define base structure
2 parents e282053 + 19243ce commit 533a028

File tree

94 files changed

+4942
-2575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+4942
-2575
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
parser: '@typescript-eslint/parser',
33
parserOptions: {
44
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
56
sourceType: 'module',
67
},
78
plugins: ['@typescript-eslint/eslint-plugin'],
@@ -12,6 +13,7 @@ module.exports = {
1213
root: true,
1314
env: {
1415
node: true,
16+
jest: true,
1517
},
1618
ignorePatterns: ['.eslintrc.js'],
1719
rules: {

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18.14.0-alpine AS builder
1+
FROM node:18.18.0-alpine AS builder
22

33
WORKDIR /usr/src/app
44

@@ -12,7 +12,7 @@ RUN apk add git && yarn install \
1212

1313
RUN yarn run build
1414

15-
FROM node:18.14.0-alpine AS production
15+
FROM node:18.18.0-alpine AS production
1616

1717
ARG NODE_ENV=production
1818
ENV NODE_ENV=${NODE_ENV}

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
IMGNAME?=ghcr.io/libertech-fr/mailrest
22
APPNAME?=mailrest
3-
APPPORT?=7000
3+
APPPORT?=7200
44

55
init:
66
@docker build -t $(IMGNAME) .
@@ -22,7 +22,7 @@ dev:
2222
--add-host host.docker.internal:host-gateway \
2323
--name $(APPNAME) \
2424
--network dev \
25-
-p $(APPPORT):7000 \
25+
-p $(APPPORT):7200 \
2626
-v $(CURDIR):/usr/src/app \
2727
$(IMGNAME) yarn start:dev
2828

@@ -46,8 +46,8 @@ dbs:
4646
redis
4747

4848
stop:
49-
@docker stop $(APPNAME)-redis || true
5049
@docker stop $(APPNAME) || true
50+
@docker stop $(APPNAME)-redis || true
5151

5252
rm:
5353
docker rm $(shell docker ps -a -q -f name=$(APPNAME))

nest-cli.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"sourceRoot": "src",
55
"root": "src",
66
"compilerOptions": {
7+
"deleteOutDir": true,
78
"assets": [
89
"**/*.hbs",
910
"config/**/*",

package.json

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@libertech/mailrest",
2+
"name": "@libertech-fr/mailrest",
33
"version": "0.0.1",
44
"description": "An email retrieval system with a REST API built with NestJS in NodeJS",
55
"contributors": [
@@ -26,61 +26,75 @@
2626
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
2727
"start": "nest start",
2828
"generate": "nest g resource",
29+
"npm-check-updates": "npx npm-check-updates",
2930
"start:dev": "nest start --watch",
3031
"start:debug": "nest start --debug --watch",
3132
"start:prod": "node dist/main",
32-
"console": "node dist/console"
33+
"console": "node dist/src/console"
3334
},
3435
"dependencies": {
3536
"@nestjs-modules/ioredis": "^1.0.1",
36-
"@nestjs-modules/mailer": "^1.8.1",
37-
"@nestjs/common": "^9.0.11",
38-
"@nestjs/config": "^2.2.0",
39-
"@nestjs/core": "^9.0.11",
40-
"@nestjs/jwt": "^9.0.0",
41-
"@nestjs/mapped-types": "^1.2.0",
42-
"@nestjs/passport": "^9.0.0",
43-
"@nestjs/platform-express": "^9.0.11",
44-
"@nestjs/testing": "^9.2.1",
37+
"@nestjs-modules/mailer": "^1.9.1",
38+
"@nestjs/axios": "^3.0.0",
39+
"@nestjs/common": "^10.1.3",
40+
"@nestjs/config": "^3.0.0",
41+
"@nestjs/core": "^10.1.3",
42+
"@nestjs/jwt": "^10.1.0",
43+
"@nestjs/mapped-types": "^2.0.2",
44+
"@nestjs/passport": "^10.0.0",
45+
"@nestjs/platform-express": "^10.1.3",
46+
"@nestjs/schedule": "^3.0.4",
47+
"@nestjs/testing": "^10.1.3",
48+
"axios": "^1.5.0",
4549
"class-transformer": "^0.5.1",
46-
"class-validator": "^0.13.2",
47-
"handlebars": "^4.7.7",
48-
"ioredis": "^4.0.0",
49-
"nest-commander": "^3.0.0",
50-
"nodemailer": "^6.8.0",
50+
"class-validator": "^0.14.0",
51+
"form-data": "^4.0.0",
52+
"handlebars": "^4.7.8",
53+
"imapflow": "^1.0.136",
54+
"ioredis": "^5.3.2",
55+
"lru-cache": "^10.0.1",
56+
"mailparser": "^3.6.5",
57+
"nest-access-control": "^3.0.0",
58+
"nest-commander": "^3.11.1",
59+
"nodemailer": "^6.9.4",
5160
"passport": "^0.6.0",
52-
"passport-jwt": "^4.0.0",
61+
"passport-jwt": "^4.0.1",
62+
"radash": "^11.0.0",
5363
"reflect-metadata": "^0.1.13",
54-
"rxjs": "^7.2.0",
64+
"rxjs": "^7.8.1",
5565
"yaml": "^2.3.1"
5666
},
5767
"devDependencies": {
5868
"@babel/plugin-proposal-private-methods": "^7.18.6",
5969
"@compodoc/compodoc": "^1.1.21",
60-
"@nestjs/cli": "8.2.6",
61-
"@nestjs/schematics": "8.0.11",
62-
"@nestjs/swagger": "^7.1.6",
63-
"@types/express": "^4.17.13",
70+
"@nestjs/cli": "^10.1.12",
71+
"@nestjs/schematics": "10.0.2",
72+
"@nestjs/swagger": "^7.1.8",
73+
"@types/express": "^4.17.17",
74+
"@types/form-data": "^2.5.0",
75+
"@types/imapflow": "^1.0.13",
6476
"@types/ioredis": "^4.28.10",
65-
"@types/jest": "^29.2.4",
77+
"@types/jest": "^29.5.3",
78+
"@types/lru-cache": "^7.10.10",
79+
"@types/mailparser": "^3.4.0",
6680
"@types/multer": "^1.4.7",
67-
"@types/node": "^16.0.0",
81+
"@types/node": "^18.0.0",
6882
"@types/nodemailer": "^6.4.9",
69-
"@types/passport-jwt": "^3.0.6",
70-
"@typescript-eslint/eslint-plugin": "^4.28.2",
71-
"@typescript-eslint/parser": "^4.28.2",
72-
"eslint": "^7.30.0",
73-
"eslint-config-prettier": "^8.3.0",
74-
"eslint-plugin-prettier": "^3.4.0",
75-
"prettier": "^2.3.2",
76-
"rimraf": "^3.0.2",
83+
"@types/passport-jwt": "^3.0.9",
84+
"@typescript-eslint/eslint-plugin": "^6.4.0",
85+
"@typescript-eslint/parser": "^6.4.0",
86+
"eslint": "^8.47.0",
87+
"eslint-config-prettier": "^9.0.0",
88+
"eslint-plugin-prettier": "^5.0.0",
89+
"prettier": "^3.0.2",
90+
"rimraf": "^5.0.1",
7791
"swagger-themes": "^1.2.30",
78-
"ts-loader": "^9.2.3",
79-
"ts-node": "^10.0.0",
80-
"tsconfig-paths": "^3.10.1",
92+
"ts-loader": "^9.4.4",
93+
"ts-node": "^10.9.1",
94+
"tsconfig-paths": "^4.2.0",
8195
"types-package-json": "^2.0.39",
82-
"typescript": "^4.9.5",
83-
"webpack": "^5.64.4"
96+
"typescript": "^5.1.6",
97+
"webpack": "^5.88.2"
8498
},
8599
"peerDependencies": {
86100
"express": "^4"

src/abstract.controller.ts renamed to src/_common/abstracts/abstract.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ModuleRef } from '@nestjs/core'
2-
import { AbstractService } from '~/abstract.service'
2+
import { AbstractService } from '~/_common/abstracts/abstract.service'
33

44
export abstract class AbstractController {
55
protected abstract service?: AbstractService
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ModuleRef } from '@nestjs/core'
2+
import { Request } from "express";
23

34
export abstract class AbstractService {
45
protected moduleRef: ModuleRef
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { applyDecorators, Type } from '@nestjs/common'
2+
import { ApiBody, ApiBodyOptions, ApiExtraModels, getSchemaPath } from '@nestjs/swagger'
3+
4+
export const ApiBodyDecorator = <TModel extends Type<any>>(
5+
model: TModel,
6+
options?: ApiBodyOptions | null | undefined,
7+
) => {
8+
return applyDecorators(
9+
ApiExtraModels(model),
10+
ApiBody({
11+
schema: {
12+
$ref: getSchemaPath(model),
13+
},
14+
...options,
15+
}),
16+
)
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { applyDecorators, Type } from '@nestjs/common'
2+
import { ApiBodyOptions } from '@nestjs/swagger'
3+
import { ApiBodyDecorator } from '~/_common/decorators/api-body.decorator'
4+
import { ApiResponseOptions } from '@nestjs/swagger/dist/decorators/api-response.decorator'
5+
import { ApiCreatedResponseDecorator } from '~/_common/decorators/api-created-response.decorator'
6+
7+
export const ApiCreateDecorator = <TModel extends Type<any>>(
8+
bodyModel: TModel,
9+
responseModel: TModel,
10+
bodyOptions?: ApiBodyOptions | null | undefined,
11+
responseOptions?: ApiResponseOptions | null | undefined,
12+
) => {
13+
return applyDecorators(
14+
ApiBodyDecorator(bodyModel, bodyOptions),
15+
ApiCreatedResponseDecorator(responseModel, responseOptions),
16+
)
17+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { applyDecorators, HttpStatus, Type } from '@nestjs/common'
2+
import { ApiBadRequestResponse, ApiCreatedResponse, ApiExtraModels, getSchemaPath } from '@nestjs/swagger'
3+
import { ApiResponseOptions } from '@nestjs/swagger/dist/decorators/api-response.decorator'
4+
import { ErrorSchemaDto } from '~/_common/dto/error-schema.dto'
5+
6+
export const ApiCreatedResponseDecorator = <TModel extends Type<any>>(
7+
model: TModel,
8+
options?: ApiResponseOptions | null | undefined,
9+
) => {
10+
return applyDecorators(
11+
ApiExtraModels(model),
12+
ApiExtraModels(ErrorSchemaDto),
13+
ApiCreatedResponse({
14+
schema: {
15+
properties: {
16+
statusCode: {
17+
type: 'number',
18+
enum: [HttpStatus.CREATED],
19+
},
20+
data: {
21+
$ref: getSchemaPath(model),
22+
}
23+
}
24+
},
25+
...options,
26+
}),
27+
ApiBadRequestResponse({
28+
description: 'Schema validation failed',
29+
schema: {
30+
$ref: getSchemaPath(ErrorSchemaDto),
31+
},
32+
}),
33+
)
34+
}

0 commit comments

Comments
 (0)