mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-29 00:17:48 +01:00
change null to undefined in request params check
This commit is contained in:
@@ -13,8 +13,8 @@ docsRouter.post("/docs/new", async ctx => {
|
||||
const { user } = ctx.state;
|
||||
|
||||
const { name, content } = ctx.request.body as {
|
||||
name: string | null;
|
||||
content: string | null;
|
||||
name: string | undefined;
|
||||
content: string | undefined;
|
||||
};
|
||||
|
||||
if (!(name && content)) {
|
||||
@@ -47,7 +47,7 @@ docsRouter.patch("/docs/byID/:id", async ctx => {
|
||||
const { user } = ctx.state;
|
||||
|
||||
const { id } = ctx.params as {
|
||||
id: number | null;
|
||||
id: number | undefined;
|
||||
};
|
||||
|
||||
if (!id) {
|
||||
@@ -55,8 +55,8 @@ docsRouter.patch("/docs/byID/:id", async ctx => {
|
||||
}
|
||||
|
||||
const { name, content } = ctx.request.body as {
|
||||
name: string | null;
|
||||
content: string | null;
|
||||
name: string | undefined;
|
||||
content: string | undefined;
|
||||
};
|
||||
|
||||
const document = await Document.findOne({ id, user: user.id });
|
||||
@@ -113,7 +113,7 @@ docsRouter.get("/docs/byID/:id", async ctx => {
|
||||
}
|
||||
|
||||
const { id } = ctx.params as {
|
||||
id: number | null;
|
||||
id: number | undefined;
|
||||
};
|
||||
|
||||
if (!id) {
|
||||
@@ -144,7 +144,7 @@ docsRouter.delete("/docs/byID/:id", async ctx => {
|
||||
}
|
||||
|
||||
const { id } = ctx.params as {
|
||||
id: number | null;
|
||||
id: number | undefined;
|
||||
};
|
||||
|
||||
if (!id) {
|
||||
|
||||
@@ -22,8 +22,8 @@ userRouter.post("/users/login", async ctx => {
|
||||
ctx.throw(400);
|
||||
}
|
||||
const { username, password } = request.body as {
|
||||
username: string | null;
|
||||
password: string | null;
|
||||
username: string | undefined;
|
||||
password: string | undefined;
|
||||
};
|
||||
|
||||
if (!(username && password)) {
|
||||
@@ -46,9 +46,9 @@ userRouter.post("/users/signup", async ctx => {
|
||||
}
|
||||
|
||||
const { username, password, email } = request.body as {
|
||||
username: string | null;
|
||||
password: string | null;
|
||||
email: string | null;
|
||||
username: string | undefined;
|
||||
password: string | undefined;
|
||||
email: string | undefined;
|
||||
};
|
||||
|
||||
if (!(username && password && email)) {
|
||||
|
||||
Reference in New Issue
Block a user