![]()
{
+ const [username, setUsername] = useState("");
+ const [password, setPassword] = useState("");
+ const login = useLogin();
+ const notify = useNotify();
+ const BASE_URI = process.env.REACT_APP_SERVER_URL;
+ const submit = (e: any) => {
+ e.preventDefault();
+ login({ username, password }).catch(() =>
+ notify("Invalid username or password")
+ );
+ };
+
+ return (
+
+ );
+};
+
+export default LoginForm;
diff --git a/admin-ui/src/author/AuthorCreate.tsx b/admin-ui/src/author/AuthorCreate.tsx
index 3f93478..61d3edb 100644
--- a/admin-ui/src/author/AuthorCreate.tsx
+++ b/admin-ui/src/author/AuthorCreate.tsx
@@ -17,13 +17,12 @@ export const AuthorCreate = (props: CreateProps): React.ReactElement => {
- value && value.map((v: any) => ({ id: v }))}
- format={(value: any) => value && value.map((v: any) => v.id)}
- >
-
+
+ value && value.map((v: any) => ({ id: v }))}
+ format={(value: any) => value && value.map((v: any) => v.id)}
+ />
diff --git a/admin-ui/src/author/AuthorEdit.tsx b/admin-ui/src/author/AuthorEdit.tsx
index 1dbeecb..bd22478 100644
--- a/admin-ui/src/author/AuthorEdit.tsx
+++ b/admin-ui/src/author/AuthorEdit.tsx
@@ -17,13 +17,12 @@ export const AuthorEdit = (props: EditProps): React.ReactElement => {
- value && value.map((v: any) => ({ id: v }))}
- format={(value: any) => value && value.map((v: any) => v.id)}
- >
-
+
+ value && value.map((v: any) => ({ id: v }))}
+ format={(value: any) => value && value.map((v: any) => v.id)}
+ />
diff --git a/admin-ui/src/author/AuthorList.tsx b/admin-ui/src/author/AuthorList.tsx
index 2c9be98..3eb5309 100644
--- a/admin-ui/src/author/AuthorList.tsx
+++ b/admin-ui/src/author/AuthorList.tsx
@@ -4,14 +4,8 @@ import Pagination from "../Components/Pagination";
export const AuthorList = (props: ListProps): React.ReactElement => {
return (
-
}
- >
-
+
}>
+
@@ -19,7 +13,7 @@ export const AuthorList = (props: ListProps): React.ReactElement => {
-
+ {" "}
);
diff --git a/admin-ui/src/author/AuthorShow.tsx b/admin-ui/src/author/AuthorShow.tsx
index 5235d64..f5d8696 100644
--- a/admin-ui/src/author/AuthorShow.tsx
+++ b/admin-ui/src/author/AuthorShow.tsx
@@ -27,7 +27,7 @@ export const AuthorShow = (props: ShowProps): React.ReactElement => {
-
+
- ,
- document.getElementById("root")
+
);
-
-// If you want to start measuring performance in your app, pass a function
-// to log results (for example: reportWebVitals(console.log))
-// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
-reportWebVitals();
diff --git a/admin-ui/src/pages/Dashboard.tsx b/admin-ui/src/pages/Dashboard.tsx
index 39c4d18..29776bc 100644
--- a/admin-ui/src/pages/Dashboard.tsx
+++ b/admin-ui/src/pages/Dashboard.tsx
@@ -1,6 +1,6 @@
import * as React from "react";
-import Card from "@material-ui/core/Card";
-import CardContent from "@material-ui/core/CardContent";
+import Card from "@mui/material/Card";
+import CardContent from "@mui/material/CardContent";
import { Title } from "react-admin";
const Dashboard = () => (
diff --git a/admin-ui/src/post/PostCreate.tsx b/admin-ui/src/post/PostCreate.tsx
index 2fab91f..0569159 100644
--- a/admin-ui/src/post/PostCreate.tsx
+++ b/admin-ui/src/post/PostCreate.tsx
@@ -30,13 +30,12 @@ export const PostCreate = (props: CreateProps): React.ReactElement => {
- value && value.map((v: any) => ({ id: v }))}
- format={(value: any) => value && value.map((v: any) => v.id)}
- >
-
+
+ value && value.map((v: any) => ({ id: v }))}
+ format={(value: any) => value && value.map((v: any) => v.id)}
+ />
diff --git a/admin-ui/src/story/StoryList.tsx b/admin-ui/src/story/StoryList.tsx
index 3d5c735..19a4d39 100644
--- a/admin-ui/src/story/StoryList.tsx
+++ b/admin-ui/src/story/StoryList.tsx
@@ -11,14 +11,8 @@ import Pagination from "../Components/Pagination";
export const StoryList = (props: ListProps): React.ReactElement => {
return (
-
}
- >
-
+
}>
+
@@ -31,7 +25,7 @@ export const StoryList = (props: ListProps): React.ReactElement => {
-
+ {" "}
);
diff --git a/admin-ui/src/tag/TagCreate.tsx b/admin-ui/src/tag/TagCreate.tsx
index 741833b..969b65a 100644
--- a/admin-ui/src/tag/TagCreate.tsx
+++ b/admin-ui/src/tag/TagCreate.tsx
@@ -16,13 +16,12 @@ export const TagCreate = (props: CreateProps): React.ReactElement => {
- value && value.map((v: any) => ({ id: v }))}
- format={(value: any) => value && value.map((v: any) => v.id)}
- >
-
+
+ value && value.map((v: any) => ({ id: v }))}
+ format={(value: any) => value && value.map((v: any) => v.id)}
+ />
diff --git a/admin-ui/src/tag/TagEdit.tsx b/admin-ui/src/tag/TagEdit.tsx
index 7159f64..28303e6 100644
--- a/admin-ui/src/tag/TagEdit.tsx
+++ b/admin-ui/src/tag/TagEdit.tsx
@@ -16,13 +16,12 @@ export const TagEdit = (props: EditProps): React.ReactElement => {
- value && value.map((v: any) => ({ id: v }))}
- format={(value: any) => value && value.map((v: any) => v.id)}
- >
-
+
+ value && value.map((v: any) => ({ id: v }))}
+ format={(value: any) => value && value.map((v: any) => v.id)}
+ />
diff --git a/admin-ui/src/tag/TagList.tsx b/admin-ui/src/tag/TagList.tsx
index 9592f7a..b729fbb 100644
--- a/admin-ui/src/tag/TagList.tsx
+++ b/admin-ui/src/tag/TagList.tsx
@@ -4,19 +4,13 @@ import Pagination from "../Components/Pagination";
export const TagList = (props: ListProps): React.ReactElement => {
return (
-
}
- >
-
+
}>
+
-
+ {" "}
);
diff --git a/admin-ui/src/theme/theme.ts b/admin-ui/src/theme/theme.ts
index 56a1153..bcfca0e 100644
--- a/admin-ui/src/theme/theme.ts
+++ b/admin-ui/src/theme/theme.ts
@@ -1,7 +1,7 @@
import { defaultTheme } from "react-admin";
-import { createTheme, ThemeOptions } from "@material-ui/core/styles";
+import { createTheme, ThemeOptions } from "@mui/material/styles";
import { merge } from "lodash";
-import createPalette from "@material-ui/core/styles/createPalette";
+import createPalette from "@mui/material/styles/createPalette";
const palette = createPalette(
merge({}, defaultTheme.palette, {
diff --git a/admin-ui/src/user/RolesOptions.ts b/admin-ui/src/user/RolesOptions.ts
index 2f12fcf..5e30fe9 100644
--- a/admin-ui/src/user/RolesOptions.ts
+++ b/admin-ui/src/user/RolesOptions.ts
@@ -1,4 +1,3 @@
-//@ts-ignore
import { ROLES } from "./roles";
declare interface Role {
diff --git a/admin-ui/src/user/UserList.tsx b/admin-ui/src/user/UserList.tsx
index aa820f4..c5adf63 100644
--- a/admin-ui/src/user/UserList.tsx
+++ b/admin-ui/src/user/UserList.tsx
@@ -4,21 +4,15 @@ import Pagination from "../Components/Pagination";
export const UserList = (props: ListProps): React.ReactElement => {
return (
-
}
- >
-
+
}>
+
-
+ {" "}
);
diff --git a/admin-ui/src/vite-env.d.ts b/admin-ui/src/vite-env.d.ts
new file mode 100644
index 0000000..11f02fe
--- /dev/null
+++ b/admin-ui/src/vite-env.d.ts
@@ -0,0 +1 @@
+///
diff --git a/admin-ui/vite.config.ts b/admin-ui/vite.config.ts
new file mode 100644
index 0000000..cf64d08
--- /dev/null
+++ b/admin-ui/vite.config.ts
@@ -0,0 +1,14 @@
+import { defineConfig } from "vite";
+import react from "@vitejs/plugin-react";
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ plugins: [react()],
+ define: {
+ "process.env": process.env,
+ },
+ server: {
+ host: true,
+ },
+ base: "./",
+});
diff --git a/server/.env b/server/.env
index 0cc8cc2..c1e11ce 100644
--- a/server/.env
+++ b/server/.env
@@ -1,10 +1,10 @@
BCRYPT_SALT=10
COMPOSE_PROJECT_NAME=amp_ckyrgxqh2135618801s6xmf6elb7
-PORT=3000
-DB_URL=postgres://admin:admin@localhost:5432/my-db
-DB_USER=admin
+DB_NAME=my-db
DB_PASSWORD=admin
DB_PORT=5432
-DB_NAME=my-db
+DB_URL=postgres://admin:admin@localhost:5432/my-db
+DB_USER=admin
+JWT_EXPIRATION=2d
JWT_SECRET_KEY=Change_ME!!!
-JWT_EXPIRATION=2d
\ No newline at end of file
+PORT=3000
\ No newline at end of file
diff --git a/server/README.md b/server/README.md
index 6db8e75..bca0445 100644
--- a/server/README.md
+++ b/server/README.md
@@ -1,6 +1,6 @@
-
+
diff --git a/server/docker-compose.yml b/server/docker-compose.yml
index 189f745..2a466f3 100644
--- a/server/docker-compose.yml
+++ b/server/docker-compose.yml
@@ -9,9 +9,9 @@ services:
- ${PORT}:3000
environment:
BCRYPT_SALT: ${BCRYPT_SALT}
- DB_URL: postgres://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
JWT_EXPIRATION: ${JWT_EXPIRATION}
+ DB_URL: postgres://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
depends_on:
- migrate
restart: on-failure
diff --git a/server/nest-cli.json b/server/nest-cli.json
index fe51713..b7b60ae 100644
--- a/server/nest-cli.json
+++ b/server/nest-cli.json
@@ -1,6 +1,10 @@
{
"sourceRoot": "src",
"compilerOptions": {
- "assets": ["swagger"]
+ "assets": [
+ {
+ "include": "swagger/**/*"
+ }
+ ]
}
}
diff --git a/server/package.json b/server/package.json
index 6ee9cc7..93b6bd3 100644
--- a/server/package.json
+++ b/server/package.json
@@ -44,7 +44,7 @@
"passport-http": "0.3.0",
"passport-jwt": "4.0.1",
"reflect-metadata": "0.1.13",
- "ts-node": "10.9.1",
+ "ts-node": "10.9.2",
"type-fest": "2.19.0",
"validator": "13.11.0"
},
@@ -64,11 +64,14 @@
"prisma": "^5.4.2",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1",
- "typescript": "^5.2.2"
+ "typescript": "^5.4.3"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
+ "moduleNameMapper": {
+ "@app/custom-validators": "/src/validators"
+ },
"modulePathIgnorePatterns": ["/dist/"]
}
}
diff --git a/server/src/auth/IAuthStrategy.ts b/server/src/auth/IAuthStrategy.ts
index 5db10cf..7406267 100644
--- a/server/src/auth/IAuthStrategy.ts
+++ b/server/src/auth/IAuthStrategy.ts
@@ -1,5 +1,6 @@
import { UserInfo } from "./UserInfo";
export interface IAuthStrategy {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
validate: (...any: any) => Promise;
}
diff --git a/server/src/auth/acl.module.ts b/server/src/auth/acl.module.ts
index eb90005..040e7e5 100644
--- a/server/src/auth/acl.module.ts
+++ b/server/src/auth/acl.module.ts
@@ -1,6 +1,5 @@
import { AccessControlModule, RolesBuilder } from "nest-access-control";
-// @ts-ignore
-// eslint-disable-next-line import/no-unresolved
+
import grants from "../grants.json";
// eslint-disable-next-line @typescript-eslint/naming-convention
diff --git a/server/src/auth/gqlDefaultAuth.guard.ts b/server/src/auth/gqlDefaultAuth.guard.ts
index 0455177..abebd93 100644
--- a/server/src/auth/gqlDefaultAuth.guard.ts
+++ b/server/src/auth/gqlDefaultAuth.guard.ts
@@ -1,8 +1,6 @@
import { ExecutionContext } from "@nestjs/common";
import { GqlExecutionContext } from "@nestjs/graphql";
import type { Request } from "express";
-// @ts-ignore
-// eslint-disable-next-line
import { DefaultAuthGuard } from "./defaultAuth.guard";
export class GqlDefaultAuthGuard extends DefaultAuthGuard {
diff --git a/server/src/auth/token.service.ts b/server/src/auth/token.service.ts
index b102b72..2ee079c 100644
--- a/server/src/auth/token.service.ts
+++ b/server/src/auth/token.service.ts
@@ -1,7 +1,5 @@
-//@ts-ignore
import { ITokenService } from "./ITokenService";
-// eslint-disable-next-line import/no-unresolved
-//@ts-ignore
+
import { TokenServiceBase } from "./base/token.service.base";
export class TokenService extends TokenServiceBase implements ITokenService {}
diff --git a/server/src/author/base/Author.ts b/server/src/author/base/Author.ts
index c3beaee..2bdb62d 100644
--- a/server/src/author/base/Author.ts
+++ b/server/src/author/base/Author.ts
@@ -11,7 +11,13 @@ https://docs.amplication.com/how-to/custom-code
*/
import { ObjectType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsDate, IsString, IsOptional, ValidateNested } from "class-validator";
+import {
+ IsDate,
+ IsString,
+ MaxLength,
+ IsOptional,
+ ValidateNested,
+} from "class-validator";
import { Type } from "class-transformer";
import { Post } from "../../post/base/Post";
@@ -30,6 +36,7 @@ class Author {
type: String,
})
@IsString()
+ @MaxLength(1000)
@Field(() => String)
firstName!: string;
@@ -46,6 +53,7 @@ class Author {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -66,6 +74,7 @@ class Author {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -77,6 +86,7 @@ class Author {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -88,6 +98,7 @@ class Author {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/author/base/AuthorCreateInput.ts b/server/src/author/base/AuthorCreateInput.ts
index f90fb84..4489abd 100644
--- a/server/src/author/base/AuthorCreateInput.ts
+++ b/server/src/author/base/AuthorCreateInput.ts
@@ -11,7 +11,12 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsOptional, ValidateNested } from "class-validator";
+import {
+ IsString,
+ MaxLength,
+ IsOptional,
+ ValidateNested,
+} from "class-validator";
import { PostCreateNestedManyWithoutAuthorsInput } from "./PostCreateNestedManyWithoutAuthorsInput";
import { Type } from "class-transformer";
@@ -22,6 +27,7 @@ class AuthorCreateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@Field(() => String)
firstName!: string;
@@ -30,6 +36,7 @@ class AuthorCreateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -53,6 +60,7 @@ class AuthorCreateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -64,6 +72,7 @@ class AuthorCreateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -75,6 +84,7 @@ class AuthorCreateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/author/base/AuthorUpdateInput.ts b/server/src/author/base/AuthorUpdateInput.ts
index b82974a..f5c2086 100644
--- a/server/src/author/base/AuthorUpdateInput.ts
+++ b/server/src/author/base/AuthorUpdateInput.ts
@@ -11,7 +11,12 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsOptional, ValidateNested } from "class-validator";
+import {
+ IsString,
+ MaxLength,
+ IsOptional,
+ ValidateNested,
+} from "class-validator";
import { PostUpdateManyWithoutAuthorsInput } from "./PostUpdateManyWithoutAuthorsInput";
import { Type } from "class-transformer";
@@ -22,6 +27,7 @@ class AuthorUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -33,6 +39,7 @@ class AuthorUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -56,6 +63,7 @@ class AuthorUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -67,6 +75,7 @@ class AuthorUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -78,6 +87,7 @@ class AuthorUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/author/base/author.service.base.ts b/server/src/author/base/author.service.base.ts
index ad3ae34..1910a23 100644
--- a/server/src/author/base/author.service.base.ts
+++ b/server/src/author/base/author.service.base.ts
@@ -10,52 +10,41 @@ https://docs.amplication.com/how-to/custom-code
------------------------------------------------------------------------------
*/
import { PrismaService } from "../../prisma/prisma.service";
-
import {
Prisma,
- Author, // @ts-ignore
- Post,
+ Author as PrismaAuthor,
+ Post as PrismaPost,
} from "@prisma/client";
export class AuthorServiceBase {
constructor(protected readonly prisma: PrismaService) {}
- async count(
- args: Prisma.SelectSubset
- ): Promise {
+ async count(args: Omit): Promise {
return this.prisma.author.count(args);
}
- async authors(
- args: Prisma.SelectSubset
- ): Promise {
+ async authors(args: Prisma.AuthorFindManyArgs): Promise {
return this.prisma.author.findMany(args);
}
- async author(
- args: Prisma.SelectSubset
- ): Promise {
+ async author(
+ args: Prisma.AuthorFindUniqueArgs
+ ): Promise {
return this.prisma.author.findUnique(args);
}
- async createAuthor(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.author.create(args);
+ async createAuthor(args: Prisma.AuthorCreateArgs): Promise {
+ return this.prisma.author.create(args);
}
- async updateAuthor(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.author.update(args);
+ async updateAuthor(args: Prisma.AuthorUpdateArgs): Promise {
+ return this.prisma.author.update(args);
}
- async deleteAuthor(
- args: Prisma.SelectSubset
- ): Promise {
+ async deleteAuthor(args: Prisma.AuthorDeleteArgs): Promise {
return this.prisma.author.delete(args);
}
async findPosts(
parentId: string,
args: Prisma.PostFindManyArgs
- ): Promise {
+ ): Promise {
return this.prisma.author
.findUniqueOrThrow({
where: { id: parentId },
diff --git a/server/src/post/base/Post.ts b/server/src/post/base/Post.ts
index 8d1d7d2..af68ab5 100644
--- a/server/src/post/base/Post.ts
+++ b/server/src/post/base/Post.ts
@@ -15,6 +15,7 @@ import { Author } from "../../author/base/Author";
import {
ValidateNested,
IsString,
+ MaxLength,
IsDate,
IsBoolean,
IsOptional,
@@ -37,6 +38,7 @@ class Post {
type: String,
})
@IsString()
+ @MaxLength(99999999)
@Field(() => String)
content!: string;
@@ -64,6 +66,7 @@ class Post {
type: String,
})
@IsString()
+ @MaxLength(5000)
@Field(() => String)
featuredImage!: string;
@@ -80,6 +83,7 @@ class Post {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -91,6 +95,7 @@ class Post {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -113,6 +118,7 @@ class Post {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -133,6 +139,7 @@ class Post {
type: String,
})
@IsString()
+ @MaxLength(500)
@Field(() => String)
title!: string;
diff --git a/server/src/post/base/PostCreateInput.ts b/server/src/post/base/PostCreateInput.ts
index 9ebb375..5cd5741 100644
--- a/server/src/post/base/PostCreateInput.ts
+++ b/server/src/post/base/PostCreateInput.ts
@@ -15,6 +15,7 @@ import { AuthorWhereUniqueInput } from "../../author/base/AuthorWhereUniqueInput
import {
ValidateNested,
IsString,
+ MaxLength,
IsBoolean,
IsOptional,
IsDate,
@@ -38,6 +39,7 @@ class PostCreateInput {
type: String,
})
@IsString()
+ @MaxLength(99999999)
@Field(() => String)
content!: string;
@@ -57,6 +59,7 @@ class PostCreateInput {
type: String,
})
@IsString()
+ @MaxLength(5000)
@Field(() => String)
featuredImage!: string;
@@ -65,6 +68,7 @@ class PostCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -76,6 +80,7 @@ class PostCreateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -98,6 +103,7 @@ class PostCreateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -121,6 +127,7 @@ class PostCreateInput {
type: String,
})
@IsString()
+ @MaxLength(500)
@Field(() => String)
title!: string;
}
diff --git a/server/src/post/base/PostUpdateInput.ts b/server/src/post/base/PostUpdateInput.ts
index 88fa888..f6e1179 100644
--- a/server/src/post/base/PostUpdateInput.ts
+++ b/server/src/post/base/PostUpdateInput.ts
@@ -16,6 +16,7 @@ import {
ValidateNested,
IsOptional,
IsString,
+ MaxLength,
IsBoolean,
IsDate,
} from "class-validator";
@@ -41,6 +42,7 @@ class PostUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(99999999)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -63,6 +65,7 @@ class PostUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(5000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -74,6 +77,7 @@ class PostUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -85,6 +89,7 @@ class PostUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -107,6 +112,7 @@ class PostUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -130,6 +136,7 @@ class PostUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(500)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/post/base/post.service.base.ts b/server/src/post/base/post.service.base.ts
index 4ff5ed1..b53b671 100644
--- a/server/src/post/base/post.service.base.ts
+++ b/server/src/post/base/post.service.base.ts
@@ -10,53 +10,40 @@ https://docs.amplication.com/how-to/custom-code
------------------------------------------------------------------------------
*/
import { PrismaService } from "../../prisma/prisma.service";
-
import {
Prisma,
- Post, // @ts-ignore
- Tag, // @ts-ignore
- Author,
+ Post as PrismaPost,
+ Tag as PrismaTag,
+ Author as PrismaAuthor,
} from "@prisma/client";
export class PostServiceBase {
constructor(protected readonly prisma: PrismaService) {}
- async count(
- args: Prisma.SelectSubset
- ): Promise {
+ async count(args: Omit): Promise {
return this.prisma.post.count(args);
}
- async posts(
- args: Prisma.SelectSubset
- ): Promise {
+ async posts(args: Prisma.PostFindManyArgs): Promise {
return this.prisma.post.findMany(args);
}
- async post(
- args: Prisma.SelectSubset
- ): Promise {
+ async post(args: Prisma.PostFindUniqueArgs): Promise {
return this.prisma.post.findUnique(args);
}
- async createPost(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.post.create(args);
+ async createPost(args: Prisma.PostCreateArgs): Promise {
+ return this.prisma.post.create(args);
}
- async updatePost(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.post.update(args);
+ async updatePost(args: Prisma.PostUpdateArgs): Promise {
+ return this.prisma.post.update(args);
}
- async deletePost(
- args: Prisma.SelectSubset
- ): Promise {
+ async deletePost(args: Prisma.PostDeleteArgs): Promise {
return this.prisma.post.delete(args);
}
async findTags(
parentId: string,
args: Prisma.TagFindManyArgs
- ): Promise {
+ ): Promise {
return this.prisma.post
.findUniqueOrThrow({
where: { id: parentId },
@@ -64,7 +51,7 @@ export class PostServiceBase {
.tags(args);
}
- async getAuthor(parentId: string): Promise {
+ async getAuthor(parentId: string): Promise {
return this.prisma.post
.findUnique({
where: { id: parentId },
diff --git a/server/src/story/base/Story.ts b/server/src/story/base/Story.ts
index 3feefd8..bee68fd 100644
--- a/server/src/story/base/Story.ts
+++ b/server/src/story/base/Story.ts
@@ -11,7 +11,13 @@ https://docs.amplication.com/how-to/custom-code
*/
import { ObjectType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsDate, IsOptional, IsBoolean } from "class-validator";
+import {
+ IsString,
+ MaxLength,
+ IsDate,
+ IsOptional,
+ IsBoolean,
+} from "class-validator";
import { Type } from "class-transformer";
@ObjectType()
@@ -21,6 +27,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
content!: string;
@@ -37,6 +44,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -59,6 +67,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
featuredImage!: string;
@@ -75,6 +84,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -86,6 +96,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -108,6 +119,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -119,6 +131,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
tag!: string;
@@ -127,6 +140,7 @@ class Story {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
title!: string;
diff --git a/server/src/story/base/StoryCreateInput.ts b/server/src/story/base/StoryCreateInput.ts
index 4590422..d030291 100644
--- a/server/src/story/base/StoryCreateInput.ts
+++ b/server/src/story/base/StoryCreateInput.ts
@@ -11,7 +11,13 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsOptional, IsBoolean, IsDate } from "class-validator";
+import {
+ IsString,
+ MaxLength,
+ IsOptional,
+ IsBoolean,
+ IsDate,
+} from "class-validator";
import { Type } from "class-transformer";
@InputType()
@@ -21,6 +27,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
content!: string;
@@ -29,6 +36,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -51,6 +59,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
featuredImage!: string;
@@ -59,6 +68,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -70,6 +80,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -92,6 +103,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -103,6 +115,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
tag!: string;
@@ -111,6 +124,7 @@ class StoryCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@Field(() => String)
title!: string;
}
diff --git a/server/src/story/base/StoryUpdateInput.ts b/server/src/story/base/StoryUpdateInput.ts
index aa1dfef..89b4079 100644
--- a/server/src/story/base/StoryUpdateInput.ts
+++ b/server/src/story/base/StoryUpdateInput.ts
@@ -11,7 +11,13 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsOptional, IsBoolean, IsDate } from "class-validator";
+import {
+ IsString,
+ MaxLength,
+ IsOptional,
+ IsBoolean,
+ IsDate,
+} from "class-validator";
import { Type } from "class-transformer";
@InputType()
@@ -21,6 +27,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -32,6 +39,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -54,6 +62,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -65,6 +74,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -76,6 +86,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -98,6 +109,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -109,6 +121,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -120,6 +133,7 @@ class StoryUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/story/base/story.service.base.ts b/server/src/story/base/story.service.base.ts
index ab3a389..9a097fe 100644
--- a/server/src/story/base/story.service.base.ts
+++ b/server/src/story/base/story.service.base.ts
@@ -10,40 +10,28 @@ https://docs.amplication.com/how-to/custom-code
------------------------------------------------------------------------------
*/
import { PrismaService } from "../../prisma/prisma.service";
-import { Prisma, Story } from "@prisma/client";
+import { Prisma, Story as PrismaStory } from "@prisma/client";
export class StoryServiceBase {
constructor(protected readonly prisma: PrismaService) {}
- async count(
- args: Prisma.SelectSubset
- ): Promise {
+ async count(args: Omit): Promise {
return this.prisma.story.count(args);
}
- async stories(
- args: Prisma.SelectSubset
- ): Promise {
+ async stories(args: Prisma.StoryFindManyArgs): Promise {
return this.prisma.story.findMany(args);
}
- async story(
- args: Prisma.SelectSubset
- ): Promise {
+ async story(args: Prisma.StoryFindUniqueArgs): Promise {
return this.prisma.story.findUnique(args);
}
- async createStory(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.story.create(args);
+ async createStory(args: Prisma.StoryCreateArgs): Promise {
+ return this.prisma.story.create(args);
}
- async updateStory(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.story.update(args);
+ async updateStory(args: Prisma.StoryUpdateArgs): Promise {
+ return this.prisma.story.update(args);
}
- async deleteStory(
- args: Prisma.SelectSubset
- ): Promise {
+ async deleteStory(args: Prisma.StoryDeleteArgs): Promise {
return this.prisma.story.delete(args);
}
}
diff --git a/server/src/tag/base/Tag.ts b/server/src/tag/base/Tag.ts
index 5656491..b7e44c3 100644
--- a/server/src/tag/base/Tag.ts
+++ b/server/src/tag/base/Tag.ts
@@ -11,7 +11,13 @@ https://docs.amplication.com/how-to/custom-code
*/
import { ObjectType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsDate, IsString, ValidateNested, IsOptional } from "class-validator";
+import {
+ IsDate,
+ IsString,
+ MaxLength,
+ ValidateNested,
+ IsOptional,
+} from "class-validator";
import { Type } from "class-transformer";
import { Post } from "../../post/base/Post";
@@ -38,6 +44,7 @@ class Tag {
type: String,
})
@IsString()
+ @MaxLength(1000)
@Field(() => String)
name!: string;
@@ -55,6 +62,7 @@ class Tag {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/tag/base/TagCreateInput.ts b/server/src/tag/base/TagCreateInput.ts
index b5f1e9f..247baec 100644
--- a/server/src/tag/base/TagCreateInput.ts
+++ b/server/src/tag/base/TagCreateInput.ts
@@ -11,7 +11,12 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, ValidateNested, IsOptional } from "class-validator";
+import {
+ IsString,
+ MaxLength,
+ ValidateNested,
+ IsOptional,
+} from "class-validator";
import { PostCreateNestedManyWithoutTagsInput } from "./PostCreateNestedManyWithoutTagsInput";
import { Type } from "class-transformer";
@@ -22,6 +27,7 @@ class TagCreateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@Field(() => String)
name!: string;
@@ -42,6 +48,7 @@ class TagCreateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/tag/base/TagUpdateInput.ts b/server/src/tag/base/TagUpdateInput.ts
index 2a15891..f27f41c 100644
--- a/server/src/tag/base/TagUpdateInput.ts
+++ b/server/src/tag/base/TagUpdateInput.ts
@@ -11,7 +11,12 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsOptional, ValidateNested } from "class-validator";
+import {
+ IsString,
+ MaxLength,
+ IsOptional,
+ ValidateNested,
+} from "class-validator";
import { PostUpdateManyWithoutTagsInput } from "./PostUpdateManyWithoutTagsInput";
import { Type } from "class-transformer";
@@ -22,6 +27,7 @@ class TagUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(1000)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -45,6 +51,7 @@ class TagUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(100)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/tag/base/tag.service.base.ts b/server/src/tag/base/tag.service.base.ts
index 971e0df..325b5a7 100644
--- a/server/src/tag/base/tag.service.base.ts
+++ b/server/src/tag/base/tag.service.base.ts
@@ -10,52 +10,35 @@ https://docs.amplication.com/how-to/custom-code
------------------------------------------------------------------------------
*/
import { PrismaService } from "../../prisma/prisma.service";
-
-import {
- Prisma,
- Tag, // @ts-ignore
- Post,
-} from "@prisma/client";
+import { Prisma, Tag as PrismaTag, Post as PrismaPost } from "@prisma/client";
export class TagServiceBase {
constructor(protected readonly prisma: PrismaService) {}
- async count(
- args: Prisma.SelectSubset
- ): Promise {
+ async count(args: Omit): Promise {
return this.prisma.tag.count(args);
}
- async tags(
- args: Prisma.SelectSubset
- ): Promise {
+ async tags(args: Prisma.TagFindManyArgs): Promise {
return this.prisma.tag.findMany(args);
}
- async tag(
- args: Prisma.SelectSubset
- ): Promise {
+ async tag(args: Prisma.TagFindUniqueArgs): Promise {
return this.prisma.tag.findUnique(args);
}
- async createTag(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.tag.create(args);
+ async createTag(args: Prisma.TagCreateArgs): Promise {
+ return this.prisma.tag.create(args);
}
- async updateTag(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.tag.update(args);
+ async updateTag(args: Prisma.TagUpdateArgs): Promise {
+ return this.prisma.tag.update(args);
}
- async deleteTag(
- args: Prisma.SelectSubset
- ): Promise {
+ async deleteTag(args: Prisma.TagDeleteArgs): Promise {
return this.prisma.tag.delete(args);
}
async findPosts(
parentId: string,
args: Prisma.PostFindManyArgs
- ): Promise {
+ ): Promise {
return this.prisma.tag
.findUniqueOrThrow({
where: { id: parentId },
diff --git a/server/src/tests/auth/jwt/jwt.strategy.spec.ts b/server/src/tests/auth/jwt/jwt.strategy.spec.ts
index 2f5d1a3..36bbb24 100644
--- a/server/src/tests/auth/jwt/jwt.strategy.spec.ts
+++ b/server/src/tests/auth/jwt/jwt.strategy.spec.ts
@@ -12,7 +12,9 @@ describe("Testing the jwtStrategyBase.validate()", () => {
it("should throw UnauthorizedException where there is no user", async () => {
//ARRANGE
userService.user
- .calledWith({ where: { username: TEST_USER.username } })
+ .calledWith({
+ where: { username: TEST_USER.username },
+ })
.mockReturnValue(Promise.resolve(null));
//ACT
const result = jwtStrategy.validate({
diff --git a/server/src/user/base/User.ts b/server/src/user/base/User.ts
index 0ed8084..348fd32 100644
--- a/server/src/user/base/User.ts
+++ b/server/src/user/base/User.ts
@@ -11,7 +11,7 @@ https://docs.amplication.com/how-to/custom-code
*/
import { ObjectType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsDate, IsString, IsOptional } from "class-validator";
+import { IsDate, IsString, MaxLength, IsOptional } from "class-validator";
import { Type } from "class-transformer";
import { IsJSONValue } from "../../validators";
import { GraphQLJSON } from "graphql-type-json";
@@ -32,6 +32,7 @@ class User {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -51,6 +52,7 @@ class User {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/user/base/UserCreateInput.ts b/server/src/user/base/UserCreateInput.ts
index 617155a..a98430e 100644
--- a/server/src/user/base/UserCreateInput.ts
+++ b/server/src/user/base/UserCreateInput.ts
@@ -11,7 +11,7 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsOptional } from "class-validator";
+import { IsString, MaxLength, IsOptional } from "class-validator";
import { IsJSONValue } from "../../validators";
import { GraphQLJSON } from "graphql-type-json";
import { InputJsonValue } from "../../types";
@@ -23,6 +23,7 @@ class UserCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -34,6 +35,7 @@ class UserCreateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/user/base/UserUpdateInput.ts b/server/src/user/base/UserUpdateInput.ts
index 0a9ab93..aefeb3f 100644
--- a/server/src/user/base/UserUpdateInput.ts
+++ b/server/src/user/base/UserUpdateInput.ts
@@ -11,7 +11,7 @@ https://docs.amplication.com/how-to/custom-code
*/
import { InputType, Field } from "@nestjs/graphql";
import { ApiProperty } from "@nestjs/swagger";
-import { IsString, IsOptional } from "class-validator";
+import { IsString, MaxLength, IsOptional } from "class-validator";
import { IsJSONValue } from "../../validators";
import { GraphQLJSON } from "graphql-type-json";
import { InputJsonValue } from "../../types";
@@ -23,6 +23,7 @@ class UserUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
@@ -34,6 +35,7 @@ class UserUpdateInput {
type: String,
})
@IsString()
+ @MaxLength(256)
@IsOptional()
@Field(() => String, {
nullable: true,
diff --git a/server/src/user/base/user.service.base.ts b/server/src/user/base/user.service.base.ts
index d23387f..6a749c5 100644
--- a/server/src/user/base/user.service.base.ts
+++ b/server/src/user/base/user.service.base.ts
@@ -10,7 +10,7 @@ https://docs.amplication.com/how-to/custom-code
------------------------------------------------------------------------------
*/
import { PrismaService } from "../../prisma/prisma.service";
-import { Prisma, User } from "@prisma/client";
+import { Prisma, User as PrismaUser } from "@prisma/client";
import { PasswordService } from "../../auth/password.service";
import { transformStringFieldUpdateInput } from "../../prisma.util";
@@ -20,26 +20,18 @@ export class UserServiceBase {
protected readonly passwordService: PasswordService
) {}
- async count(
- args: Prisma.SelectSubset
- ): Promise {
+ async count(args: Omit): Promise {
return this.prisma.user.count(args);
}
- async users(
- args: Prisma.SelectSubset
- ): Promise {
+ async users(args: Prisma.UserFindManyArgs): Promise {
return this.prisma.user.findMany(args);
}
- async user(
- args: Prisma.SelectSubset
- ): Promise {
+ async user(args: Prisma.UserFindUniqueArgs): Promise {
return this.prisma.user.findUnique(args);
}
- async createUser(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.user.create({
+ async createUser(args: Prisma.UserCreateArgs): Promise {
+ return this.prisma.user.create({
...args,
data: {
@@ -48,10 +40,8 @@ export class UserServiceBase {
},
});
}
- async updateUser(
- args: Prisma.SelectSubset
- ): Promise {
- return this.prisma.user.update({
+ async updateUser(args: Prisma.UserUpdateArgs): Promise {
+ return this.prisma.user.update({
...args,
data: {
@@ -66,9 +56,7 @@ export class UserServiceBase {
},
});
}
- async deleteUser(
- args: Prisma.SelectSubset
- ): Promise {
+ async deleteUser(args: Prisma.UserDeleteArgs): Promise {
return this.prisma.user.delete(args);
}
}