This commit is contained in:
powermaker450 2024-08-18 23:45:00 -04:00
parent 34bcb07a1a
commit 6298fe8cfc
3 changed files with 19 additions and 14 deletions

View file

@ -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;

View file

@ -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(
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(),
(number) => {
!((number! * 10) % 5);
},
)
.required(),
title: string().strict(true).max(50).required(),
content: string().strict(true).max(2000).notRequired(),
});

View file

@ -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,
},
});
}
}