From 780c483083daec9c617597def25ea80b4d9923a7 Mon Sep 17 00:00:00 2001 From: "amp-122-112-229-188-yunmai[bot]" <128461903+amp-122-112-229-188-yunmai[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 08:37:02 +0000 Subject: [PATCH] =?UTF-8?q?Amplication=20build=20#=20cljcluczr0004h3v4j0zq?= =?UTF-8?q?azd4.=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20Commit=20mess?= =?UTF-8?q?age:=20=E5=93=88=E5=93=88=E5=93=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://119.3.41.106:3001/clfeshkgm0002h36wpwb9bpf7/clfeshkgs000ah36w1087xheu/clfeshufa000hh36w4vj43m5t/builds/cljcluczr0004h3v4j0zqazd4 --- .amplication/ignored/server/.env | 1 + admin-ui/src/api/user/User.ts | 2 + admin-ui/src/api/user/UserCreateInput.ts | 2 + admin-ui/src/api/user/UserOrderByInput.ts | 2 + admin-ui/src/api/user/UserUpdateInput.ts | 2 + admin-ui/src/api/user/UserWhereInput.ts | 2 + admin-ui/src/user/UserCreate.tsx | 2 + admin-ui/src/user/UserEdit.tsx | 2 + admin-ui/src/user/UserList.tsx | 2 + admin-ui/src/user/UserShow.tsx | 2 + server/package.json | 73 ------------------- server/prisma/schema.prisma | 2 + server/scripts/seed.ts | 49 ------------- server/src/app.module.ts | 53 -------------- server/src/swagger.ts | 2 +- server/src/user/base/User.ts | 22 ++++++ server/src/user/base/UserCreateInput.ts | 22 ++++++ server/src/user/base/UserOrderByInput.ts | 18 +++++ server/src/user/base/UserUpdateInput.ts | 22 ++++++ server/src/user/base/UserWhereInput.ts | 22 ++++++ .../user/base/user.controller.base.spec.ts | 8 ++ server/src/user/base/user.controller.base.ts | 10 +++ 22 files changed, 146 insertions(+), 176 deletions(-) delete mode 100644 server/package.json delete mode 100644 server/scripts/seed.ts delete mode 100644 server/src/app.module.ts diff --git a/.amplication/ignored/server/.env b/.amplication/ignored/server/.env index 59ebfd6..8b6b515 100644 --- a/.amplication/ignored/server/.env +++ b/.amplication/ignored/server/.env @@ -5,5 +5,6 @@ DB_URL=postgres://admin:admin@localhost:5432/my-db DB_USER=admin DB_PASSWORD=admin DB_PORT=5432 +DB_NAME=my-db JWT_SECRET_KEY=Change_ME!!! JWT_EXPIRATION=2d \ No newline at end of file diff --git a/admin-ui/src/api/user/User.ts b/admin-ui/src/api/user/User.ts index 4e86caf..ab01be9 100644 --- a/admin-ui/src/api/user/User.ts +++ b/admin-ui/src/api/user/User.ts @@ -8,4 +8,6 @@ export type User = { lastName: string | null; username: string; roles: JsonValue; + age: string | null; + course: string | null; }; diff --git a/admin-ui/src/api/user/UserCreateInput.ts b/admin-ui/src/api/user/UserCreateInput.ts index cd7fa5a..0eae04c 100644 --- a/admin-ui/src/api/user/UserCreateInput.ts +++ b/admin-ui/src/api/user/UserCreateInput.ts @@ -6,4 +6,6 @@ export type UserCreateInput = { username: string; password: string; roles: InputJsonValue; + age?: string | null; + course?: string | null; }; diff --git a/admin-ui/src/api/user/UserOrderByInput.ts b/admin-ui/src/api/user/UserOrderByInput.ts index cde82ed..1e3bae5 100644 --- a/admin-ui/src/api/user/UserOrderByInput.ts +++ b/admin-ui/src/api/user/UserOrderByInput.ts @@ -9,4 +9,6 @@ export type UserOrderByInput = { username?: SortOrder; password?: SortOrder; roles?: SortOrder; + age?: SortOrder; + course?: SortOrder; }; diff --git a/admin-ui/src/api/user/UserUpdateInput.ts b/admin-ui/src/api/user/UserUpdateInput.ts index e4fc533..4039fce 100644 --- a/admin-ui/src/api/user/UserUpdateInput.ts +++ b/admin-ui/src/api/user/UserUpdateInput.ts @@ -6,4 +6,6 @@ export type UserUpdateInput = { username?: string; password?: string; roles?: InputJsonValue; + age?: string | null; + course?: string | null; }; diff --git a/admin-ui/src/api/user/UserWhereInput.ts b/admin-ui/src/api/user/UserWhereInput.ts index fcd81c7..3fa62a2 100644 --- a/admin-ui/src/api/user/UserWhereInput.ts +++ b/admin-ui/src/api/user/UserWhereInput.ts @@ -6,4 +6,6 @@ export type UserWhereInput = { firstName?: StringNullableFilter; lastName?: StringNullableFilter; username?: StringFilter; + age?: StringNullableFilter; + course?: StringNullableFilter; }; diff --git a/admin-ui/src/user/UserCreate.tsx b/admin-ui/src/user/UserCreate.tsx index dfda515..2cbc64a 100644 --- a/admin-ui/src/user/UserCreate.tsx +++ b/admin-ui/src/user/UserCreate.tsx @@ -25,6 +25,8 @@ export const UserCreate = (props: CreateProps): React.ReactElement => { optionText="label" optionValue="value" /> + + ); diff --git a/admin-ui/src/user/UserEdit.tsx b/admin-ui/src/user/UserEdit.tsx index 57aa95e..30877d5 100644 --- a/admin-ui/src/user/UserEdit.tsx +++ b/admin-ui/src/user/UserEdit.tsx @@ -23,6 +23,8 @@ export const UserEdit = (props: EditProps): React.ReactElement => { optionText="label" optionValue="value" /> + + ); diff --git a/admin-ui/src/user/UserList.tsx b/admin-ui/src/user/UserList.tsx index 87afc5e..d1a5ce0 100644 --- a/admin-ui/src/user/UserList.tsx +++ b/admin-ui/src/user/UserList.tsx @@ -19,6 +19,8 @@ export const UserList = (props: ListProps): React.ReactElement => { + + ); diff --git a/admin-ui/src/user/UserShow.tsx b/admin-ui/src/user/UserShow.tsx index 5e9d39d..b8ee0b6 100644 --- a/admin-ui/src/user/UserShow.tsx +++ b/admin-ui/src/user/UserShow.tsx @@ -18,6 +18,8 @@ export const UserShow = (props: ShowProps): React.ReactElement => { + + ); diff --git a/server/package.json b/server/package.json deleted file mode 100644 index ad7b671..0000000 --- a/server/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@my-service/server", - "private": true, - "scripts": { - "start": "nest start", - "start:watch": "nest start --watch", - "start:debug": "nest start --debug --watch", - "build": "nest build", - "test": "jest", - "seed": "ts-node scripts/seed.ts", - "db:migrate-save": "prisma migrate dev", - "db:migrate-up": "prisma migrate deploy", - "db:clean": "ts-node scripts/clean.ts", - "db:init": "run-s \"db:migrate-save -- --name 'initial version'\" db:migrate-up seed", - "prisma:generate": "prisma generate", - "docker:db": "docker-compose -f docker-compose.db.yml up -d", - "docker:build": "docker build .", - "compose:up": "docker-compose up -d", - "compose:down": "docker-compose down --volumes" - }, - "dependencies": { - "@nestjs/common": "8.4.7", - "@nestjs/config": "1.1.5", - "@nestjs/core": "8.4.7", - "@nestjs/graphql": "9.1.2", - "@nestjs/platform-express": "8.4.7", - "@nestjs/serve-static": "2.2.2", - "@nestjs/swagger": "5.1.5", - "@prisma/client": "4.6.1", - "apollo-server-express": "3.6.1", - "bcrypt": "5.0.1", - "class-transformer": "0.5.1", - "class-validator": "0.13.2", - "graphql": "15.7.2", - "graphql-type-json": "0.3.2", - "nest-access-control": "2.0.3", - "nest-morgan": "1.0.1", - "nestjs-prisma": "0.19.0", - "npm-run-all": "4.1.5", - "reflect-metadata": "0.1.13", - "swagger-ui-express": "4.3.0", - "ts-node": "9.1.1", - "@nestjs/jwt": "^10.0.2", - "@nestjs/passport": "^9.0.0", - "passport": "0.6.0", - "passport-http": "0.3.0", - "passport-jwt": "4.0.1" - }, - "devDependencies": { - "@nestjs/cli": "8.2.5", - "@nestjs/testing": "8.4.7", - "@types/bcrypt": "5.0.0", - "@types/express": "4.17.9", - "@types/graphql-type-json": "0.3.2", - "@types/jest": "26.0.19", - "@types/normalize-path": "3.0.0", - "@types/supertest": "2.0.11", - "jest": "27.0.6", - "jest-mock-extended": "^2.0.4", - "prisma": "4.6.1", - "supertest": "4.0.2", - "ts-jest": "27.0.3", - "type-fest": "0.11.0", - "typescript": "4.2.3", - "@types/passport-http": "0.3.9", - "@types/passport-jwt": "3.0.8" - }, - "jest": { - "preset": "ts-jest", - "testEnvironment": "node", - "modulePathIgnorePatterns": ["/dist/"] - } -} diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index 81ef875..e64bf96 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -16,4 +16,6 @@ model User { username String @unique password String roles Json + age String? + course String? } diff --git a/server/scripts/seed.ts b/server/scripts/seed.ts deleted file mode 100644 index 272dddd..0000000 --- a/server/scripts/seed.ts +++ /dev/null @@ -1,49 +0,0 @@ -import * as dotenv from "dotenv"; -import { PrismaClient } from "@prisma/client"; -import { customSeed } from "./customSeed"; -import { Salt, parseSalt } from "../src/auth/password.service"; -import { hash } from "bcrypt"; - -if (require.main === module) { - dotenv.config(); - - const { BCRYPT_SALT } = process.env; - - if (!BCRYPT_SALT) { - throw new Error("BCRYPT_SALT environment variable must be defined"); - } - const salt = parseSalt(BCRYPT_SALT); - - seed(salt).catch((error) => { - console.error(error); - process.exit(1); - }); -} - -async function seed(bcryptSalt: Salt) { - console.info("Seeding database..."); - - const client = new PrismaClient(); - - const data = { - username: "admin", - password: await hash("admin", bcryptSalt), - roles: ["user"], - }; - - await client.user.upsert({ - where: { - username: data.username, - }, - - update: {}, - create: data, - }); - - void client.$disconnect(); - - console.info("Seeding database with custom seed..."); - customSeed(); - - console.info("Seeded database successfully"); -} diff --git a/server/src/app.module.ts b/server/src/app.module.ts deleted file mode 100644 index d6433fb..0000000 --- a/server/src/app.module.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Module, Scope } from "@nestjs/common"; -import { APP_INTERCEPTOR } from "@nestjs/core"; -import { MorganInterceptor, MorganModule } from "nest-morgan"; -import { UserModule } from "./user/user.module"; -import { HealthModule } from "./health/health.module"; -import { PrismaModule } from "./prisma/prisma.module"; -import { SecretsManagerModule } from "./providers/secrets/secretsManager.module"; -import { ConfigModule, ConfigService } from "@nestjs/config"; -import { ServeStaticModule } from "@nestjs/serve-static"; -import { ServeStaticOptionsService } from "./serveStaticOptions.service"; -import { GraphQLModule } from "@nestjs/graphql"; - -import { ACLModule } from "./auth/acl.module"; -import { AuthModule } from "./auth/auth.module"; - -@Module({ - controllers: [], - imports: [ - ACLModule, - AuthModule, - UserModule, - HealthModule, - PrismaModule, - SecretsManagerModule, - MorganModule, - ConfigModule.forRoot({ isGlobal: true }), - ServeStaticModule.forRootAsync({ - useClass: ServeStaticOptionsService, - }), - GraphQLModule.forRootAsync({ - useFactory: (configService) => { - const playground = configService.get("GRAPHQL_PLAYGROUND"); - const introspection = configService.get("GRAPHQL_INTROSPECTION"); - return { - autoSchemaFile: "schema.graphql", - sortSchema: true, - playground, - introspection: playground || introspection, - }; - }, - inject: [ConfigService], - imports: [ConfigModule], - }), - ], - providers: [ - { - provide: APP_INTERCEPTOR, - scope: Scope.REQUEST, - useClass: MorganInterceptor("combined"), - }, - ], -}) -export class AppModule {} diff --git a/server/src/swagger.ts b/server/src/swagger.ts index eb21a8e..c074d1f 100644 --- a/server/src/swagger.ts +++ b/server/src/swagger.ts @@ -7,7 +7,7 @@ export const swaggerDocumentOptions = new DocumentBuilder() .setDescription( '\n\n## Congratulations! Your service resource is ready.\n \nPlease note that all endpoints are secured with JWT Bearer authentication.\nBy default, your service resource comes with one user with the username "admin" and password "admin".\nLearn more in [our docs](https://docs.amplication.com)' ) - .setVersion("1104a18s") + .setVersion("cl1rt26k") .addBearerAuth() .build(); diff --git a/server/src/user/base/User.ts b/server/src/user/base/User.ts index e4f12cd..dd25cb5 100644 --- a/server/src/user/base/User.ts +++ b/server/src/user/base/User.ts @@ -78,6 +78,28 @@ class User { @IsJSON() @Field(() => GraphQLJSON) roles!: JsonValue; + + @ApiProperty({ + required: false, + type: String, + }) + @IsString() + @IsOptional() + @Field(() => String, { + nullable: true, + }) + age!: string | null; + + @ApiProperty({ + required: false, + type: String, + }) + @IsString() + @IsOptional() + @Field(() => String, { + nullable: true, + }) + course!: string | null; } export { User as User }; diff --git a/server/src/user/base/UserCreateInput.ts b/server/src/user/base/UserCreateInput.ts index 398f9b4..6964572 100644 --- a/server/src/user/base/UserCreateInput.ts +++ b/server/src/user/base/UserCreateInput.ts @@ -61,6 +61,28 @@ class UserCreateInput { @IsJSON() @Field(() => GraphQLJSON) roles!: InputJsonValue; + + @ApiProperty({ + required: false, + type: String, + }) + @IsString() + @IsOptional() + @Field(() => String, { + nullable: true, + }) + age?: string | null; + + @ApiProperty({ + required: false, + type: String, + }) + @IsString() + @IsOptional() + @Field(() => String, { + nullable: true, + }) + course?: string | null; } export { UserCreateInput as UserCreateInput }; diff --git a/server/src/user/base/UserOrderByInput.ts b/server/src/user/base/UserOrderByInput.ts index a76564c..b9068ec 100644 --- a/server/src/user/base/UserOrderByInput.ts +++ b/server/src/user/base/UserOrderByInput.ts @@ -89,6 +89,24 @@ class UserOrderByInput { nullable: true, }) roles?: SortOrder; + + @ApiProperty({ + required: false, + enum: ["asc", "desc"], + }) + @Field(() => SortOrder, { + nullable: true, + }) + age?: SortOrder; + + @ApiProperty({ + required: false, + enum: ["asc", "desc"], + }) + @Field(() => SortOrder, { + nullable: true, + }) + course?: SortOrder; } export { UserOrderByInput as UserOrderByInput }; diff --git a/server/src/user/base/UserUpdateInput.ts b/server/src/user/base/UserUpdateInput.ts index c0bd636..62291e3 100644 --- a/server/src/user/base/UserUpdateInput.ts +++ b/server/src/user/base/UserUpdateInput.ts @@ -70,6 +70,28 @@ class UserUpdateInput { nullable: true, }) roles?: InputJsonValue; + + @ApiProperty({ + required: false, + type: String, + }) + @IsString() + @IsOptional() + @Field(() => String, { + nullable: true, + }) + age?: string | null; + + @ApiProperty({ + required: false, + type: String, + }) + @IsString() + @IsOptional() + @Field(() => String, { + nullable: true, + }) + course?: string | null; } export { UserUpdateInput as UserUpdateInput }; diff --git a/server/src/user/base/UserWhereInput.ts b/server/src/user/base/UserWhereInput.ts index 00bc16b..3ed9ac8 100644 --- a/server/src/user/base/UserWhereInput.ts +++ b/server/src/user/base/UserWhereInput.ts @@ -61,6 +61,28 @@ class UserWhereInput { nullable: true, }) username?: StringFilter; + + @ApiProperty({ + required: false, + type: StringNullableFilter, + }) + @Type(() => StringNullableFilter) + @IsOptional() + @Field(() => StringNullableFilter, { + nullable: true, + }) + age?: StringNullableFilter; + + @ApiProperty({ + required: false, + type: StringNullableFilter, + }) + @Type(() => StringNullableFilter) + @IsOptional() + @Field(() => StringNullableFilter, { + nullable: true, + }) + course?: StringNullableFilter; } export { UserWhereInput as UserWhereInput }; diff --git a/server/src/user/base/user.controller.base.spec.ts b/server/src/user/base/user.controller.base.spec.ts index f3def16..49e801d 100644 --- a/server/src/user/base/user.controller.base.spec.ts +++ b/server/src/user/base/user.controller.base.spec.ts @@ -26,6 +26,8 @@ const CREATE_INPUT = { lastName: "exampleLastName", username: "exampleUsername", password: "examplePassword", + age: "exampleAge", + course: "exampleCourse", }; const CREATE_RESULT = { id: "exampleId", @@ -35,6 +37,8 @@ const CREATE_RESULT = { lastName: "exampleLastName", username: "exampleUsername", password: "examplePassword", + age: "exampleAge", + course: "exampleCourse", }; const FIND_MANY_RESULT = [ { @@ -45,6 +49,8 @@ const FIND_MANY_RESULT = [ lastName: "exampleLastName", username: "exampleUsername", password: "examplePassword", + age: "exampleAge", + course: "exampleCourse", }, ]; const FIND_ONE_RESULT = { @@ -55,6 +61,8 @@ const FIND_ONE_RESULT = { lastName: "exampleLastName", username: "exampleUsername", password: "examplePassword", + age: "exampleAge", + course: "exampleCourse", }; const service = { diff --git a/server/src/user/base/user.controller.base.ts b/server/src/user/base/user.controller.base.ts index 02d3c7f..049e6d1 100644 --- a/server/src/user/base/user.controller.base.ts +++ b/server/src/user/base/user.controller.base.ts @@ -57,6 +57,8 @@ export class UserControllerBase { lastName: true, username: true, roles: true, + age: true, + course: true, }, }); } @@ -85,6 +87,8 @@ export class UserControllerBase { lastName: true, username: true, roles: true, + age: true, + course: true, }, }); } @@ -114,6 +118,8 @@ export class UserControllerBase { lastName: true, username: true, roles: true, + age: true, + course: true, }, }); if (result === null) { @@ -152,6 +158,8 @@ export class UserControllerBase { lastName: true, username: true, roles: true, + age: true, + course: true, }, }); } catch (error) { @@ -189,6 +197,8 @@ export class UserControllerBase { lastName: true, username: true, roles: true, + age: true, + course: true, }, }); } catch (error) {