Significant API progress
This commit is contained in:
parent
ea72d194c2
commit
01227bb28f
27 changed files with 2378 additions and 0 deletions
23
backend/src/app/util/Logger.ts
Normal file
23
backend/src/app/util/Logger.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { Request } from "express";
|
||||
import winston from "winston";
|
||||
|
||||
export const LOGGER = winston.createLogger({
|
||||
level: "info",
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
winston.format.json()
|
||||
),
|
||||
defaultMeta: { service: "api" },
|
||||
transports: [
|
||||
new winston.transports.File({ filename: "error.log", level: "error" }),
|
||||
new winston.transports.File({ filename: "combined.log" }),
|
||||
],
|
||||
});
|
||||
|
||||
export const logAccess = (req: Request) => {
|
||||
LOGGER.info(
|
||||
`Accessed endpoint ${req.path}. User is ${
|
||||
req.user ? "authenticated" : "not authenticated"
|
||||
}`
|
||||
);
|
||||
};
|
||||
Loading…
Reference in a new issue