本文整理匯總了TypeScript中restify.Server.pre方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Server.pre方法的具體用法?TypeScript Server.pre怎麽用?TypeScript Server.pre使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類restify.Server
的用法示例。
在下文中一共展示了Server.pre方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: require
import logger from "./logging.config";
import * as restify from "restify";
import {Server} from "restify";
import {registerActionsInExpressApp} from "controllers.ts/Factory";
import {ControllerRunner} from "controllers.ts/ControllerRunner";
let config = require("../../package.json");
let port = process.env.PORT || 3000;
let host = process.env.HOST || "localhost";
logger.info("Setting up restify...");
const server: Server = restify.createServer({
name: config.name,
version: config.version
});
server.pre(restify.pre.sanitizePath());
const controllerRunner: ControllerRunner = registerActionsInExpressApp(server, [__dirname + "/../api"]);
controllerRunner.container = {
get: function (someClass: any): any {
logger.info("Setting up restify...");
return kernel.get(someClass.name);
}
};
server.listen(port, host, () => logger.info(`${server.name}@${config.version} listening at ${host}:${port}`));