ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -57,6 +57,14 @@ export async function expressAuthentication(
|
|||
break;
|
||||
}
|
||||
|
||||
if (!request.app.locals.logData) {
|
||||
request.app.locals.logData = {};
|
||||
}
|
||||
|
||||
request.app.locals.logData.userId = payload.sub;
|
||||
request.app.locals.logData.userName = payload.name;
|
||||
request.app.locals.logData.user = payload.preferred_username;
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import { ValidateError } from "tsoa";
|
||||
|
||||
function error(error: Error, _req: Request, res: Response, _next: NextFunction) {
|
||||
const logData = _req.app.locals.logData.sequence?.at(-1);
|
||||
if (logData) {
|
||||
logData.status = "error";
|
||||
logData.description = error.message;
|
||||
}
|
||||
|
||||
if (error instanceof HttpError) {
|
||||
return res.status(error.status).json({
|
||||
status: error.status,
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
let system = "org";
|
||||
if (req.url.startsWith("/api/v1/org/metadata/")) system="metadata";
|
||||
if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/profile/")) system = "profile";
|
||||
// if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
// if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
|
||||
const level = LOG_LEVEL_MAP[process.env.LOG_LEVEL ?? "debug"] || 4;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue