Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {AfterRoutesInit} from "@tsed/common";
import {Constant, Module} from "@tsed/di";
import {$log} from "ts-log-debug";
import {ISeqSettings} from "./interfaces/ISeqSettings";
@Module()
export class SeqModule implements AfterRoutesInit {
@Constant("seq", {
url: "http://localhost:5341"
})
private config: ISeqSettings;
$afterRoutesInit() {
$log.appenders.set("seq", {
type: "seq",
levels: ["info", "debug", "trace", "fatal", "error", "warn"],
url: this.config.url,
apiKey: this.config.apiKey
});
}
}
import {Constant} from "@tsed/di";
import * as Express from "express";
import {Exception} from "ts-httpexceptions";
import {Err, IMiddlewareError, IResponseError, Middleware, Req, Res} from "../../mvc";
/**
* @middleware
*/
@Middleware()
export class GlobalErrorHandlerMiddleware implements IMiddlewareError {
@Constant("errors.headerName", "errors")
protected headerName: string;
use(@Err() error: any, @Req() request: Req, @Res() response: Res): any {
const toHTML = (message = "") => message.replace(/\n/gi, "<br>");
if (error instanceof Exception || error.status) {
request.log.error({
error: {
message: error.message,
stack: error.stack,
status: error.status,
origin: error.origin
}
});
this.setHeaders(response, error, error.origin);
import {$log} from "ts-log-debug";
import {colorize} from "ts-log-debug/lib/layouts/utils/colorizeUtils";
import {AfterRoutesInit} from "../../server/interfaces/AfterRoutesInit";
import {ControllerProvider} from "../class/ControllerProvider";
import {EndpointMetadata} from "../class/EndpointMetadata";
import {IControllerRoute} from "../interfaces";
/**
* `RouteService` is used to provide all routes collected by annotation `@Controller`.
*/
@Service()
export class RouteService implements AfterRoutesInit {
/**
*
*/
@Constant("logger.disableRoutesSummary", false)
disableRoutesSummary: boolean;
private readonly _routes: {route: string; provider: any}[] = [];
constructor(private injector: InjectorService) {}
/**
*
* @returns {{route: string; provider: any}[]}
*/
get routes(): {route: string; provider: any}[] {
return this._routes || [];
}
/**
*