Create custom type for IdRequest
This commit is contained in:
parent
9161427968
commit
35f5d3d071
|
@ -1,7 +1,6 @@
|
|||
import { userReviewSchema, typeJson } from "../types";
|
||||
import { bold, emp, Logger, responder, data } from "../utils";
|
||||
import { Express, Request, Response } from "express";
|
||||
import { ReviewData } from "../utils/ReviewData";
|
||||
|
||||
export class PostListener {
|
||||
private server: Express;
|
||||
|
@ -65,5 +64,7 @@ export class PostListener {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
this.logger.log("Loading complete.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Express, Request, Response } from "express";
|
||||
import { Logger, data, emp } from "../utils";
|
||||
import { typeJson } from "../types";
|
||||
import { IdRequest, typeJson } from "../types";
|
||||
|
||||
export class MessagesResponder {
|
||||
private server: Express;
|
||||
|
@ -22,7 +22,7 @@ export class MessagesResponder {
|
|||
this.logger.log(`${emp(receiver)} <~ "${req.path}"`);
|
||||
});
|
||||
|
||||
this.server.get("/reviews/:id", (req: Request, res: Response) => {
|
||||
this.server.get("/reviews/:id", (req: IdRequest, res: Response) => {
|
||||
const receiver = req.headers["user-agent"];
|
||||
const result = data.getReviewById(req.params.id);
|
||||
|
||||
|
@ -31,6 +31,8 @@ export class MessagesResponder {
|
|||
res.end();
|
||||
|
||||
this.logger.log(`${emp(receiver)} <~ "${req.path}"`);
|
||||
})
|
||||
});
|
||||
|
||||
this.logger.log("Loading complete.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { object, string, number, InferType } from "yup";
|
||||
import { Request } from "express";
|
||||
|
||||
const rating = number()
|
||||
.positive()
|
||||
|
@ -26,3 +27,9 @@ export const serverReviewSchema = userReviewSchema.shape({
|
|||
export type UserSideReview = InferType<typeof userReviewSchema>;
|
||||
export type ServerSideReview = InferType<typeof serverReviewSchema>;
|
||||
export type userRating = InferType<typeof rating>;
|
||||
|
||||
export interface IdRequest extends Request {
|
||||
params: {
|
||||
id: string
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue