Skip to content

Commit 19243ce

Browse files
committed
WIP first testable version
1 parent 2efe634 commit 19243ce

File tree

87 files changed

+2811
-1231
lines changed

Some content is hidden

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

87 files changed

+2811
-1231
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"singleQuote": true,
55
"trailingComma": "all",
66
"arrowParens": "always",
7-
"printWidth": 180,
7+
"printWidth": 150,
88
"bracketSpacing": true
99
}

.vscode/settings.json

Lines changed: 0 additions & 2 deletions
This file was deleted.

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))

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,31 @@
3030
"start:dev": "nest start --watch",
3131
"start:debug": "nest start --debug --watch",
3232
"start:prod": "node dist/main",
33-
"console": "node dist/console"
33+
"console": "node dist/src/console"
3434
},
3535
"dependencies": {
3636
"@nestjs-modules/ioredis": "^1.0.1",
3737
"@nestjs-modules/mailer": "^1.9.1",
38+
"@nestjs/axios": "^3.0.0",
3839
"@nestjs/common": "^10.1.3",
3940
"@nestjs/config": "^3.0.0",
4041
"@nestjs/core": "^10.1.3",
4142
"@nestjs/jwt": "^10.1.0",
4243
"@nestjs/mapped-types": "^2.0.2",
4344
"@nestjs/passport": "^10.0.0",
4445
"@nestjs/platform-express": "^10.1.3",
46+
"@nestjs/schedule": "^3.0.4",
4547
"@nestjs/testing": "^10.1.3",
48+
"axios": "^1.5.0",
4649
"class-transformer": "^0.5.1",
4750
"class-validator": "^0.14.0",
51+
"form-data": "^4.0.0",
4852
"handlebars": "^4.7.8",
4953
"imapflow": "^1.0.136",
5054
"ioredis": "^5.3.2",
5155
"lru-cache": "^10.0.1",
5256
"mailparser": "^3.6.5",
57+
"nest-access-control": "^3.0.0",
5358
"nest-commander": "^3.11.1",
5459
"nodemailer": "^6.9.4",
5560
"passport": "^0.6.0",
@@ -66,13 +71,14 @@
6671
"@nestjs/schematics": "10.0.2",
6772
"@nestjs/swagger": "^7.1.8",
6873
"@types/express": "^4.17.17",
74+
"@types/form-data": "^2.5.0",
6975
"@types/imapflow": "^1.0.13",
7076
"@types/ioredis": "^4.28.10",
7177
"@types/jest": "^29.5.3",
7278
"@types/lru-cache": "^7.10.10",
7379
"@types/mailparser": "^3.4.0",
7480
"@types/multer": "^1.4.7",
75-
"@types/node": "^20.5.0",
81+
"@types/node": "^18.0.0",
7682
"@types/nodemailer": "^6.4.9",
7783
"@types/passport-jwt": "^3.0.9",
7884
"@typescript-eslint/eslint-plugin": "^6.4.0",

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)