change null to undefined in request params check

This commit is contained in:
2019-01-12 23:50:00 +03:00
parent c437d3269e
commit a3122cbf41
2 changed files with 12 additions and 12 deletions

View File

@@ -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) {

View File

@@ -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)) {