Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reerer (Amplication build vccba2qe) #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .amplication/ignored/server/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ DB_URL=postgres://admin:admin@localhost:5432/my-db
DB_USER=admin
DB_PASSWORD=admin
DB_PORT=5432
JWT_SECRET_KEY=Change_ME!!!
JWT_EXPIRATION=2d
DB_NAME=my-db
2 changes: 2 additions & 0 deletions admin-ui/src/api/user/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export type User = {
lastName: string | null;
username: string;
roles: JsonValue;
age: string | null;
course: string | null;
};
2 changes: 2 additions & 0 deletions admin-ui/src/api/user/UserCreateInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export type UserCreateInput = {
username: string;
password: string;
roles: InputJsonValue;
age?: string | null;
course?: string | null;
};
2 changes: 2 additions & 0 deletions admin-ui/src/api/user/UserOrderByInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export type UserOrderByInput = {
username?: SortOrder;
password?: SortOrder;
roles?: SortOrder;
age?: SortOrder;
course?: SortOrder;
};
2 changes: 2 additions & 0 deletions admin-ui/src/api/user/UserUpdateInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export type UserUpdateInput = {
username?: string;
password?: string;
roles?: InputJsonValue;
age?: string | null;
course?: string | null;
};
2 changes: 2 additions & 0 deletions admin-ui/src/api/user/UserWhereInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export type UserWhereInput = {
firstName?: StringNullableFilter;
lastName?: StringNullableFilter;
username?: StringFilter;
age?: StringNullableFilter;
course?: StringNullableFilter;
};
2 changes: 2 additions & 0 deletions admin-ui/src/user/UserCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const UserCreate = (props: CreateProps): React.ReactElement => {
optionText="label"
optionValue="value"
/>
<TextInput label="age" source="age" />
<TextInput label="course" source="course" />
</SimpleForm>
</Create>
);
Expand Down
2 changes: 2 additions & 0 deletions admin-ui/src/user/UserEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const UserEdit = (props: EditProps): React.ReactElement => {
optionText="label"
optionValue="value"
/>
<TextInput label="age" source="age" />
<TextInput label="course" source="course" />
</SimpleForm>
</Edit>
);
Expand Down
2 changes: 2 additions & 0 deletions admin-ui/src/user/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const UserList = (props: ListProps): React.ReactElement => {
<TextField label="Last Name" source="lastName" />
<TextField label="Username" source="username" />
<TextField label="Roles" source="roles" />
<TextField label="age" source="age" />
<TextField label="course" source="course" />
</Datagrid>
</List>
);
Expand Down
2 changes: 2 additions & 0 deletions admin-ui/src/user/UserShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const UserShow = (props: ShowProps): React.ReactElement => {
<TextField label="Last Name" source="lastName" />
<TextField label="Username" source="username" />
<TextField label="Roles" source="roles" />
<TextField label="age" source="age" />
<TextField label="course" source="course" />
</SimpleShowLayout>
</Show>
);
Expand Down
11 changes: 2 additions & 9 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
"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"
"ts-node": "9.1.1"
},
"devDependencies": {
"@nestjs/cli": "8.2.5",
Expand All @@ -61,9 +56,7 @@
"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"
"typescript": "4.2.3"
},
"jest": {
"preset": "ts-jest",
Expand Down
2 changes: 2 additions & 0 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ model User {
username String @unique
password String
roles Json
age String?
course String?
}
26 changes: 1 addition & 25 deletions server/scripts/seed.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
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();
Expand All @@ -12,34 +10,12 @@ if (require.main === module) {
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) {
async function seed() {
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...");
Expand Down
5 changes: 0 additions & 5 deletions server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ 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,
Expand Down
2 changes: 1 addition & 1 deletion server/src/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("6uk4779j")
.addBearerAuth()
.build();

Expand Down
22 changes: 22 additions & 0 deletions server/src/user/base/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
22 changes: 22 additions & 0 deletions server/src/user/base/UserCreateInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
18 changes: 18 additions & 0 deletions server/src/user/base/UserOrderByInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
22 changes: 22 additions & 0 deletions server/src/user/base/UserUpdateInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
22 changes: 22 additions & 0 deletions server/src/user/base/UserWhereInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
8 changes: 8 additions & 0 deletions server/src/user/base/user.controller.base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const CREATE_INPUT = {
lastName: "exampleLastName",
username: "exampleUsername",
password: "examplePassword",
age: "exampleAge",
course: "exampleCourse",
};
const CREATE_RESULT = {
id: "exampleId",
Expand All @@ -35,6 +37,8 @@ const CREATE_RESULT = {
lastName: "exampleLastName",
username: "exampleUsername",
password: "examplePassword",
age: "exampleAge",
course: "exampleCourse",
};
const FIND_MANY_RESULT = [
{
Expand All @@ -45,6 +49,8 @@ const FIND_MANY_RESULT = [
lastName: "exampleLastName",
username: "exampleUsername",
password: "examplePassword",
age: "exampleAge",
course: "exampleCourse",
},
];
const FIND_ONE_RESULT = {
Expand All @@ -55,6 +61,8 @@ const FIND_ONE_RESULT = {
lastName: "exampleLastName",
username: "exampleUsername",
password: "examplePassword",
age: "exampleAge",
course: "exampleCourse",
};

const service = {
Expand Down
Loading