Add basic logging for queries
This commit is contained in:
parent
18df0a7a6a
commit
d866fbcb62
|
@ -1,5 +1,5 @@
|
|||
import { Express, Request, Response } from "express";
|
||||
import { Logger, data } from "../utils";
|
||||
import { Logger, data, emp } from "../utils";
|
||||
import { typeJson } from "../types";
|
||||
|
||||
export class MessagesResponder {
|
||||
|
@ -12,19 +12,25 @@ export class MessagesResponder {
|
|||
|
||||
public async start(): Promise<void> {
|
||||
this.server.get("/reviews", (req: Request, res: Response) => {
|
||||
const receiver = req.headers["user-agent"];
|
||||
const result = data.getReviews();
|
||||
|
||||
res.writeHead(200, typeJson);
|
||||
res.write(JSON.stringify(result));
|
||||
res.end();
|
||||
|
||||
this.logger.log(`${emp(receiver)} <~ "${req.path}"`);
|
||||
});
|
||||
|
||||
this.server.get("/reviews/:id", (req: Request, res: Response) => {
|
||||
const receiver = req.headers["user-agent"];
|
||||
const result = data.getReviewById(req.params.id);
|
||||
|
||||
res.writeHead(200, typeJson);
|
||||
res.write(JSON.stringify(result));
|
||||
res.end();
|
||||
|
||||
this.logger.log(`${emp(receiver)} <~ "${req.path}"`);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue