Skip to content

29 files changed

+131
-195
lines changed

apps/temporary-admin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Introduction
88

9-
This service was generated with Amplication. It serves as the client-side for the generated server component. The client-side consist of a React application with ready-made forms for creating and editing the different data models of the application. It is pre-conffigured to work with the server and comes with the boilerplate and foundation for the client - i.e., routing, navigation, authentication, premissions, menu, breadcrumbs, error handling and much more. Additional information about the admin component and the architecture around it, can be found on the [documentation](https://docs.amplication.com/guides/getting-started) site. This side of the generated project was bootstrapped with [create-react-app](https://github.com/facebook/create-react-app) and built with [react-admin](https://marmelab.com/react-admin/).
9+
This service was generated with Amplication. It serves as the client-side for the generated server component. The client-side consist of a React application with ready-made forms for creating and editing the different data models of the application. It is pre-conffigured to work with the server and comes with the boilerplate and foundation for the client - i.e., routing, navigation, authentication, permissions, menu, breadcrumbs, error handling and much more. Additional information about the admin component and the architecture around it, can be found on the [documentation](https://docs.amplication.com/guides/getting-started) site. This side of the generated project was bootstrapped with [create-react-app](https://github.com/facebook/create-react-app) and built with [react-admin](https://marmelab.com/react-admin/).
1010

1111

1212
<p align="center">

apps/temporary/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ services:
99
- ${PORT}:3000
1010
environment:
1111
BCRYPT_SALT: ${BCRYPT_SALT}
12+
DB_URL: postgres://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
1213
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
1314
JWT_EXPIRATION: ${JWT_EXPIRATION}
14-
DB_URL: postgres://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
1515
depends_on:
1616
- migrate
17+
restart: on-failure
1718
migrate:
1819
build:
1920
context: .

apps/temporary/package.json

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"seed": "ts-node scripts/seed.ts",
1111
"db:migrate-save": "prisma migrate dev",
1212
"db:migrate-up": "prisma migrate deploy",
13-
"db:clean": "ts-node scripts/clean.ts",
13+
"db:clean": "prisma migrate reset",
1414
"db:init": "run-s \"db:migrate-save -- --name 'initial version'\" db:migrate-up seed",
1515
"prisma:generate": "prisma generate",
1616
"docker:dev": "docker-compose -f docker-compose.dev.yml up -d",
@@ -19,53 +19,52 @@
1919
"compose:down": "docker-compose down --volumes"
2020
},
2121
"dependencies": {
22-
"@nestjs/common": "8.4.7",
23-
"@nestjs/config": "1.1.5",
24-
"@nestjs/core": "8.4.7",
25-
"@nestjs/graphql": "9.1.2",
26-
"@nestjs/platform-express": "8.4.7",
27-
"@nestjs/serve-static": "2.2.2",
28-
"@nestjs/swagger": "5.1.5",
22+
"@apollo/server": "^4.9.4",
23+
"@nestjs/apollo": "12.0.9",
24+
"@nestjs/common": "10.2.7",
25+
"@nestjs/config": "3.1.1",
26+
"@nestjs/core": "10.2.7",
27+
"@nestjs/graphql": "12.0.9",
28+
"@nestjs/jwt": "^10.1.1",
29+
"@nestjs/passport": "^10.0.2",
30+
"@nestjs/platform-express": "10.2.7",
31+
"@nestjs/serve-static": "4.0.0",
32+
"@nestjs/swagger": "7.1.13",
33+
"@prisma/client": "^5.4.2",
2934
"@types/bcrypt": "5.0.0",
30-
"@prisma/client": "4.6.1",
31-
"apollo-server-express": "3.6.1",
32-
"bcrypt": "5.0.1",
35+
"bcrypt": "5.1.1",
3336
"class-transformer": "0.5.1",
3437
"class-validator": "0.14.0",
35-
"dotenv": "^16.1.4",
36-
"graphql": "15.7.2",
38+
"dotenv": "16.3.1",
39+
"graphql": "^16.8.1",
3740
"graphql-type-json": "0.3.2",
38-
"nest-access-control": "2.0.3",
39-
"nest-morgan": "1.0.1",
41+
"nest-access-control": "^3.1.0",
4042
"npm-run-all": "4.1.5",
41-
"reflect-metadata": "0.1.13",
42-
"swagger-ui-express": "4.3.0",
43-
"ts-node": "10.9.1",
44-
"type-fest": "0.13.1",
45-
"validator": "^13.9.0",
46-
"@nestjs/jwt": "^10.0.2",
47-
"@nestjs/passport": "^9.0.0",
4843
"passport": "0.6.0",
4944
"passport-http": "0.3.0",
50-
"passport-jwt": "4.0.1"
45+
"passport-jwt": "4.0.1",
46+
"reflect-metadata": "0.1.13",
47+
"ts-node": "10.9.1",
48+
"type-fest": "2.19.0",
49+
"validator": "13.11.0"
5150
},
5251
"devDependencies": {
53-
"@nestjs/cli": "8.2.5",
54-
"@nestjs/testing": "8.4.7",
55-
"@types/express": "4.17.9",
56-
"@types/graphql-type-json": "0.3.2",
57-
"@types/jest": "26.0.19",
52+
"@nestjs/cli": "^10.1.18",
53+
"@nestjs/testing": "^10.2.7",
54+
"@types/express": "^4.17.19",
55+
"@types/graphql-type-json": "0.3.3",
56+
"@types/jest": "^29.5.5",
5857
"@types/normalize-path": "3.0.0",
59-
"@types/supertest": "2.0.11",
60-
"@types/validator": "^13.7.15",
61-
"jest": "27.0.6",
62-
"jest-mock-extended": "^2.0.4",
63-
"prisma": "4.6.1",
64-
"supertest": "4.0.2",
65-
"ts-jest": "27.0.3",
66-
"typescript": "4.3.5",
6758
"@types/passport-http": "0.3.9",
68-
"@types/passport-jwt": "3.0.8"
59+
"@types/passport-jwt": "3.0.10",
60+
"@types/supertest": "^2.0.14",
61+
"@types/validator": "^13.11.2",
62+
"jest": "^29.7.0",
63+
"jest-mock-extended": "^3.0.5",
64+
"prisma": "^5.4.2",
65+
"supertest": "^6.3.3",
66+
"ts-jest": "^29.1.1",
67+
"typescript": "^5.2.2"
6968
},
7069
"jest": {
7170
"preset": "ts-jest",

apps/temporary/scripts/clean.ts

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

apps/temporary/src/app.module.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { Module, Scope } from "@nestjs/common";
2-
import { APP_INTERCEPTOR } from "@nestjs/core";
3-
import { MorganInterceptor, MorganModule } from "nest-morgan";
1+
import { Module } from "@nestjs/common";
42
import { UserModule } from "./user/user.module";
53
import { HealthModule } from "./health/health.module";
64
import { PrismaModule } from "./prisma/prisma.module";
@@ -9,6 +7,7 @@ import { ServeStaticModule } from "@nestjs/serve-static";
97
import { ServeStaticOptionsService } from "./serveStaticOptions.service";
108
import { ConfigModule, ConfigService } from "@nestjs/config";
119
import { GraphQLModule } from "@nestjs/graphql";
10+
import { ApolloDriver, ApolloDriverConfig } from "@nestjs/apollo";
1211

1312
import { ACLModule } from "./auth/acl.module";
1413
import { AuthModule } from "./auth/auth.module";
@@ -22,13 +21,13 @@ import { AuthModule } from "./auth/auth.module";
2221
HealthModule,
2322
PrismaModule,
2423
SecretsManagerModule,
25-
MorganModule,
2624
ConfigModule.forRoot({ isGlobal: true }),
2725
ServeStaticModule.forRootAsync({
2826
useClass: ServeStaticOptionsService,
2927
}),
30-
GraphQLModule.forRootAsync({
31-
useFactory: (configService) => {
28+
GraphQLModule.forRootAsync<ApolloDriverConfig>({
29+
driver: ApolloDriver,
30+
useFactory: (configService: ConfigService) => {
3231
const playground = configService.get("GRAPHQL_PLAYGROUND");
3332
const introspection = configService.get("GRAPHQL_INTROSPECTION");
3433
return {
@@ -42,12 +41,6 @@ import { AuthModule } from "./auth/auth.module";
4241
imports: [ConfigModule],
4342
}),
4443
],
45-
providers: [
46-
{
47-
provide: APP_INTERCEPTOR,
48-
scope: Scope.REQUEST,
49-
useClass: MorganInterceptor("combined"),
50-
},
51-
],
44+
providers: [],
5245
})
5346
export class AppModule {}

apps/temporary/src/auth/abac.util.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export function getInvalidAttributes(
99
// eslint-disable-next-line @typescript-eslint/ban-types
1010
data: Object
1111
): string[] {
12-
const filteredData = permission.filter(data);
12+
// The structuredClone call is necessary because the
13+
// `Permission.filter` function doesn't consider objects
14+
// with null prototypes. And in graphql requests, the
15+
// object passed here by the request interceptor is an object
16+
// with a null prototype.
17+
const filteredData = permission.filter(structuredClone(data));
1318
return Object.keys(data).filter((key) => !(key in filteredData));
1419
}

apps/temporary/src/auth/auth.module.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { forwardRef, Module } from "@nestjs/common";
22
import { ConfigService } from "@nestjs/config";
33
import { JwtModule } from "@nestjs/jwt";
44
import { PassportModule } from "@nestjs/passport";
5-
import { JWT_EXPIRATION, JWT_SECRET_KEY } from "../constants";
5+
import { JWT_EXPIRATION } from "../constants";
66
import { SecretsManagerModule } from "../providers/secrets/secretsManager.module";
77
import { SecretsManagerService } from "../providers/secrets/secretsManager.service";
8+
import { EnumSecretsNameKey } from "../providers/secrets/secretsNameKey.enum";
89
import { AuthController } from "./auth.controller";
910
import { AuthResolver } from "./auth.resolver";
1011
import { AuthService } from "./auth.service";
@@ -25,7 +26,9 @@ import { UserModule } from "../user/user.module";
2526
secretsService: SecretsManagerService,
2627
configService: ConfigService
2728
) => {
28-
const secret = await secretsService.getSecret<string>(JWT_SECRET_KEY);
29+
const secret = await secretsService.getSecret<string>(
30+
EnumSecretsNameKey.JwtSecretKey
31+
);
2932
const expiresIn = configService.get(JWT_EXPIRATION);
3033
if (!secret) {
3134
throw new Error("Didn't get a valid jwt secret");

apps/temporary/src/auth/auth.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const USER: any = {
2727
const SIGN_TOKEN = "SIGN_TOKEN";
2828

2929
const authEntityService = {
30-
findOne(args: { where: { username: string } }): any | null {
30+
user(args: { where: { username: string } }): any | null {
3131
if (args.where.username === VALID_CREDENTIALS.username) {
3232
return USER;
3333
}

apps/temporary/src/auth/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class AuthService {
1717
username: string,
1818
password: string
1919
): Promise<UserInfo | null> {
20-
const user = await this.userService.findOne({
20+
const user = await this.userService.user({
2121
where: { username },
2222
});
2323
if (user && (await this.passwordService.compare(password, user.password))) {

apps/temporary/src/auth/gqlDefaultAuth.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { DefaultAuthGuard } from "./defaultAuth.guard";
77

88
export class GqlDefaultAuthGuard extends DefaultAuthGuard {
99
// This method is required for the interface - do not delete it.
10-
getRequest(context: ExecutionContext): Request {
10+
getRequest<Request>(context: ExecutionContext): Request {
1111
const ctx = GqlExecutionContext.create(context);
1212
return ctx.getContext<{ req: Request }>().req;
1313
}

0 commit comments

Comments
 (0)