Skip to content

Commit c4a9a73

Browse files
author
hersveit
authored
Merge pull request #23 from fullstack-development/19-update-nestjs
3.0v Update nest js with deps
2 parents fb837a4 + e4ad578 commit c4a9a73

File tree

13 files changed

+2609
-4807
lines changed

13 files changed

+2609
-4807
lines changed

api/.eslintrc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ module.exports = {
55
project: './tsconfig.eslint.json',
66
sourceType: 'module',
77
},
8-
extends: [
9-
'plugin:@typescript-eslint/recommended',
10-
'prettier/@typescript-eslint',
11-
'plugin:prettier/recommended',
12-
],
8+
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
139
root: true,
1410
env: {
1511
node: true,

api/nest-cli.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"collection": "@nestjs/schematics",
3-
"sourceRoot": "src"
3+
"sourceRoot": "src",
4+
"$schema": "https://json.schemastore.org/nest-cli"
45
}

api/package.json

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stk-api",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "",
55
"author": "",
66
"private": true,
@@ -26,76 +26,64 @@
2626
},
2727
"dependencies": {
2828
"@medibloc/nestjs-request-context": "^1.0.0",
29-
"@nestjs/common": "^7.5.1",
30-
"@nestjs/core": "^7.5.1",
31-
"@nestjs/jwt": "^7.2.0",
32-
"@nestjs/passport": "^7.1.5",
33-
"@nestjs/platform-express": "^7.5.1",
34-
"@nestjs/schedule": "^0.4.3",
29+
"@nestjs/common": "^9.0.0",
30+
"@nestjs/core": "^9.0.0",
31+
"@nestjs/jwt": "^9.0.0",
32+
"@nestjs/passport": "^9.0.0",
33+
"@nestjs/platform-express": "^9.0.0",
34+
"@nestjs/schedule": "^2.1.0",
3535
"@prisma/client": "^3.14.0",
36-
"@types/big.js": "^6.1.0",
3736
"body-parser": "^1.19.0",
3837
"class-transformer": "^0.3.1",
3938
"class-validator": "^0.12.2",
40-
"concurrently": "^6.0.0",
4139
"cookie-parser": "^1.4.6",
4240
"cross-env": "^7.0.3",
4341
"date-fns": "^2.29.3",
4442
"dotenv": "^8.2.0",
4543
"express": "^4.17.2",
46-
"iterate": "^0.1.1",
47-
"monocle-ts": "^2.3.9",
48-
"mysql2": "^2.2.5",
49-
"newtype-ts": "^0.3.4",
5044
"node-fetch": "^2.6.7",
51-
"nodemon": "^2.0.16",
5245
"passport": "^0.4.1",
53-
"passport-google-oauth20": "^2.0.0",
5446
"passport-jwt": "^4.0.0",
55-
"pg": "^8.7.1",
5647
"prisma": "^3.14.0",
5748
"ramda": "^0.27.1",
5849
"reflect-metadata": "^0.1.13",
5950
"rimraf": "^3.0.2",
60-
"rxjs": "^6.6.3",
51+
"rxjs": "^7.2.0",
6152
"swagger-ui-express": "^4.5.0",
6253
"uuid": "^8.3.2",
6354
"yamljs": "^0.3.0"
6455
},
6556
"devDependencies": {
6657
"@golevelup/ts-jest": "^0.3.2",
67-
"@nestjs/cli": "^7.5.1",
68-
"@nestjs/schematics": "^7.1.3",
69-
"@nestjs/testing": "^7.6.5",
58+
"@nestjs/cli": "^9.0.0",
59+
"@nestjs/schematics": "^9.0.0",
60+
"@nestjs/testing": "^9.0.0",
7061
"@types/cookie-parser": "^1.4.2",
71-
"@types/express": "^4.17.8",
72-
"@types/jest": "^26.0.15",
73-
"@types/multer": "^1.4.7",
74-
"@types/node": "^14.14.6",
62+
"@types/express": "^4.17.13",
63+
"@types/jest": "28.1.8",
64+
"@types/node": "^16.0.0",
7565
"@types/node-fetch": "^2.6.2",
76-
"@types/nodemailer": "^6.4.0",
77-
"@types/passport-google-oauth20": "^2.0.5",
78-
"@types/passport-jwt": "^3.0.3",
66+
"@types/passport-jwt": "^3.0.7",
7967
"@types/ramda": "^0.27.39",
80-
"@types/supertest": "^2.0.10",
68+
"@types/supertest": "^2.0.11",
8169
"@types/swagger-ui-express": "^4.1.3",
8270
"@types/uuid": "^8.3.0",
8371
"@types/yamljs": "^0.2.31",
84-
"@typescript-eslint/eslint-plugin": "^4.6.1",
85-
"@typescript-eslint/parser": "^4.6.1",
86-
"eslint": "^7.12.1",
87-
"eslint-config-prettier": "7.0.0",
72+
"@typescript-eslint/eslint-plugin": "^5.46.0",
73+
"@typescript-eslint/parser": "^5.46.0",
74+
"eslint": "^8.0.1",
75+
"eslint-config-prettier": "^8.3.0",
8876
"eslint-plugin-deprecation": "^1.2.0",
89-
"eslint-plugin-prettier": "^3.1.4",
90-
"jest": "^26.6.3",
91-
"prettier": "^2.1.2",
92-
"supertest": "^6.2.1",
93-
"ts-jest": "^26.4.3",
94-
"ts-loader": "^8.0.8",
95-
"ts-mockito": "^2.6.1",
96-
"ts-node": "^9.1.1",
97-
"tsconfig-paths": "^3.9.0",
98-
"typescript": "^4.0.5"
77+
"eslint-plugin-prettier": "^4.0.0",
78+
"jest": "28.1.3",
79+
"prettier": "^2.3.2",
80+
"source-map-support": "^0.5.20",
81+
"supertest": "^6.1.3",
82+
"ts-jest": "28.0.8",
83+
"ts-loader": "^9.2.3",
84+
"ts-node": "^10.0.0",
85+
"tsconfig-paths": "4.1.0",
86+
"typescript": "^4.9.4"
9987
},
10088
"jest": {
10189
"moduleFileExtensions": [

api/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AppController } from './../controllers/app.controller';
12
import { Module, Scope } from '@nestjs/common';
23
import { AuthController } from '../controllers/auth/auth.controller';
34
import { UserController } from '../controllers/user/user.controller';
@@ -18,6 +19,7 @@ import { DatabaseService } from '../services/database/database.service';
1819
}),
1920
AuthController,
2021
UserController,
22+
AppController,
2123
],
2224
providers: [
2325
{

api/src/core/errors.core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class BaseError<E> {
4040
}
4141
}
4242

43-
export function isError<T, E>(value: T | BaseError<E>): value is BaseError<E> {
43+
export function isError<T, E, BE extends BaseError<E>>(value: T | BE): value is BE {
4444
return value instanceof BaseError;
4545
}
4646

api/src/core/interceptor.core.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
OnModuleInit,
1111
} from '@nestjs/common';
1212
import { RequestContext } from '@medibloc/nestjs-request-context';
13-
import { from, Observable } from 'rxjs';
13+
import { from, lastValueFrom, Observable } from 'rxjs';
1414
import { catchError, map, mergeMap } from 'rxjs/operators';
1515
import { ControllerResponse } from './controller.core';
1616
import { TransactionsContext } from '../utils/transactions.utils';
@@ -47,9 +47,8 @@ export class HttpInterceptor implements NestInterceptor, OnModuleInit {
4747
this.db.Prisma.$transaction(
4848
async (prisma) => {
4949
await ctx.transactions.init(prisma);
50-
return next
51-
.handle()
52-
.pipe(
50+
return lastValueFrom(
51+
next.handle().pipe(
5352
mergeMap(async (data) => {
5453
if (data instanceof ControllerResponse) {
5554
return data;
@@ -75,8 +74,8 @@ export class HttpInterceptor implements NestInterceptor, OnModuleInit {
7574
'or a BaseError<string>',
7675
);
7776
}),
78-
)
79-
.toPromise();
77+
),
78+
);
8079
},
8180
{ maxWait: 20000, timeout: 50000 },
8281
),
@@ -142,7 +141,7 @@ export class HttpInterceptor implements NestInterceptor, OnModuleInit {
142141
if (process.env['TEST'] !== 'true') {
143142
response.send(
144143
`${R.omit(['stack'], body)}\nStack: ${
145-
process.env['FULL_PRODUCTION_MODE'] !== 'true' ? body?.stack : ''
144+
process.env['ENVIRONMENT'] !== 'prod' ? body?.stack : ''
146145
}`,
147146
);
148147
} else {

api/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as cookieParser from 'cookie-parser';
44
import { AppModule } from './app/app.module';
55
import { ConfigServiceProvider } from './services/config/config.service';
66
import { serve, setup } from 'swagger-ui-express';
7-
import { load } from 'yamljs';
7+
import * as Yaml from 'yamljs';
88
import { DatabaseServiceProvider } from './services/database/database.service';
99
import { ENVIRONMENT } from './services/config/config.model';
1010
import { INestApplication } from '@nestjs/common';
@@ -79,7 +79,7 @@ async function bootstrap() {
7979

8080
const ENV = configService.ENVIRONMENT;
8181
if (ENV === ENVIRONMENT.STAGE || ENV === ENVIRONMENT.LOCAL) {
82-
const swaggerDoc = load('src/swagger.yaml');
82+
const swaggerDoc = Yaml.load('src/swagger.yaml');
8383
app.use(
8484
'/swagger',
8585
serve,

api/src/services/config/config.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ConfigServiceProvider implements ConfigDto {
2828
const devEnvPath = path.join(process.cwd(), `env/dev.env`);
2929
const env: Partial<ConfigDto> = isDev
3030
? dotenv.parse(fs.readFileSync(devEnvPath))
31-
: process.env;
31+
: (process.env as Partial<ConfigDto>);
3232

3333
const envValidation = validateSync(ConfigDto, env);
3434
if (envValidation.status === 'fail') {

api/src/services/database/database.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class DatabaseServiceProvider {
4343
}
4444

4545
@Module({
46-
imports: [ConfigService, Logger],
46+
imports: [ConfigService],
4747
providers: [DatabaseServiceProvider],
4848
exports: [DatabaseServiceProvider],
4949
})

api/src/utils/validation.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function validate<C>(
3535
options?: ValidatorOptions,
3636
): Promise<ValidationSuccess<C> | ValidationFail> {
3737
const value = plainToClass(SchemeClass, data);
38-
return classValidate(value, options).then((errors) =>
38+
return classValidate(value as Record<string, unknown>, options).then((errors) =>
3939
errors.length > 0 ? { errors, status: 'fail' } : { value, status: 'success' },
4040
);
4141
}
@@ -46,7 +46,7 @@ export function validateSync<C>(
4646
options?: ValidatorOptions,
4747
): ValidationSuccess<C> | ValidationFail {
4848
const value = plainToClass(SchemeClass, data);
49-
const errors = classValidateSync(value, options);
49+
const errors = classValidateSync(value as Record<string, unknown>, options);
5050
return errors.length > 0 ? { errors, status: 'fail' } : { value, status: 'success' };
5151
}
5252

0 commit comments

Comments
 (0)