Prettier
This commit is contained in:
parent
34bcb07a1a
commit
6298fe8cfc
|
@ -18,7 +18,6 @@ http
|
|||
const sender = `${bold(emp("Client:"))} ${emp(req.headers["user-agent"])}`;
|
||||
|
||||
req.on("data", async (chunk) => {
|
||||
|
||||
if (req.url === "/post") {
|
||||
let data: Review[] = checkFile("data.json", "utf8");
|
||||
let temp: any;
|
||||
|
@ -69,7 +68,7 @@ http
|
|||
|
||||
req.on("end", () => {
|
||||
if (!isPost) {
|
||||
res.writeHead(404, {"Content-Type": "text/plain"});
|
||||
res.writeHead(404, { "Content-Type": "text/plain" });
|
||||
res.write(`Cannot ${req.method} ${req.url}`);
|
||||
res.end();
|
||||
}
|
||||
|
|
16
src/types.ts
16
src/types.ts
|
@ -2,11 +2,17 @@ import { object, string, number, InferType } from "yup";
|
|||
|
||||
export const reviewSchema = object({
|
||||
username: string().strict(true).max(30).required(),
|
||||
rating: number().positive().max(5).test(
|
||||
"maxDigitsAfterDecimal",
|
||||
"Rating can only have at most one integer at half intervals (.0 or .5)",
|
||||
number => { !((number! * 10) % 5) }
|
||||
).required(),
|
||||
rating: number()
|
||||
.positive()
|
||||
.max(5)
|
||||
.test(
|
||||
"maxDigitsAfterDecimal",
|
||||
"Rating can only have at most one integer at half intervals (.0 or .5)",
|
||||
(number) => {
|
||||
!((number! * 10) % 5);
|
||||
},
|
||||
)
|
||||
.required(),
|
||||
title: string().strict(true).max(50).required(),
|
||||
content: string().strict(true).max(2000).notRequired(),
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ export class Responder {
|
|||
|
||||
public success(message: string): string {
|
||||
return JSON.stringify({
|
||||
message: message
|
||||
message: message,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,8 @@ export class Responder {
|
|||
return JSON.stringify({
|
||||
error: {
|
||||
type: error.name,
|
||||
message: error.message
|
||||
}
|
||||
message: error.message,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ export class Responder {
|
|||
return JSON.stringify({
|
||||
error: {
|
||||
type: "RequestError",
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ export class Responder {
|
|||
return JSON.stringify({
|
||||
error: {
|
||||
type: "JsonError",
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue