本文整理汇总了TypeScript中serve-favicon.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: express
}).then((conn) => {
const defaultParser = bodyParser.urlencoded({ extended: true });
const server = express();
const db: ISql = new Sql();
const emailSender: IEmailSender = new EmailSender();
// controller declarations
const homeController = new HomeController(db);
const newController = new NewController(db, emailSender);
const movieController = new MovieController(db);
const playerController = new PlayerController(db);
// server setup
server.use(defaultParser);
server.use(express.static("dist/public"));
server.use(favicon(path.join(__dirname, "public", "favicon.ico")));
server.set("view engine", "pug");
server.set("views", "dist/views");
// route declarations
server.get("/", homeController.index.bind(homeController));
server.get("/new", newController.index.bind(newController));
server.post("/new", newController.postNew.bind(newController));
server.get("/movies/:id(\\d+)", movieController.get.bind(movieController));
server.get("/players/:id(\\d+)", playerController.get.bind(playerController));
server.get("/:teamId", homeController.indexTeam.bind(homeController));
server.listen(3000);
}).catch((error) => {
开发者ID:snickroger,项目名称:FantasyMovieLeague,代码行数:31,代码来源:server.ts
示例2: express
import express from 'express';
import path from 'path';
import favicon from 'serve-favicon';
import avatarsRouter from '../src/router';
const app = express();
const port = Number(process.env.PORT) || 3002;
const faviconPath = path.join(__dirname, 'favicon.ico');
app.use(favicon(faviconPath));
app.use('/avatars', avatarsRouter);
app.listen(port, () =>
console.log(`[Adorable Avatars] Running at: http://localhost:${port}`),
);
export default app;
开发者ID:adorableio,项目名称:avatars-api,代码行数:19,代码来源:server.ts
示例3: function
const initializeServer = function() {
const favicon = require("serve-favicon");
const serveStatic = require("serve-static");
const winston = require("winston");
const expressWinston = require("express-winston");
const loggerSettings = {
transports: [
new winston.transports.Console({
level: "error",
json: true,
colorize: true,
}),
],
};
const prefix: string = staticFolder + "-" + serverConfig.MATH_PROGRAM + "/";
const getList: reader.GetListFunction = reader.tutorialReader(prefix, fs);
const admin = require("./admin")(clients, serverConfig.MATH_PROGRAM);
app.use(favicon(staticFolder + "-" +
serverConfig.MATH_PROGRAM + "/favicon.ico"));
app.use(SocketIOFileUpload.router);
app.use(serveStatic(staticFolder + "-" + serverConfig.MATH_PROGRAM));
app.use(serveStatic(staticFolder + "-common"));
app.use(expressWinston.logger(loggerSettings));
app.use("/admin", admin.stats);
app.use("/getListOfTutorials", getList);
app.use(unhandled);
};
开发者ID:fhinkel,项目名称:InteractiveShell,代码行数:29,代码来源:server.ts
示例4: Config
constructor() {
this.configChangedCallback = this.configChanged;
this.config = new Config(this.configChangedCallback.bind(this));
//Using connect
this.app = connect()
.use(favicon(__dirname + '/pub/images/favicon.ico'))
.use('/admin', connect_static(__dirname + '/pub', {fallthrough: false}))
.use(bodyParser.json({ type: '*/*' }))
.use(
function(req:any, res: any) {
try {
console.log(req.body);
res.setHeader('Content-Type', 'application/json');
//Do logic
let commands = req.body["commands"];
//Hard coded for testing purposes
let ccCommand = commands[0];
let c: Color = new Color(ccCommand.color);
let result = {
"color":{
R: c.getByteArray()[0],
G: c.getByteArray()[1],
B: c.getByteArray()[2]
}
};
//response.end('Setting color to ' + c.toString());
res.end(JSON.stringify(result, null, 2));
}
catch (Error) {
console.error(Error.stack);
}
})
.listen(1234, function() {
console.log("Listening on port 1234...");
})
//Listen to EADDRINUSE (port already in use)
.on('error', (function(err: any) {
if (err.code === "EADDRINUSE") {
console.log("Port already in use. Retrying in "+this.config.getTimeout()+" seconds...");
setTimeout((function() {
this.startListening();
}).bind(this), this.config.getTimeout() * 1000);
}
}).bind(this));
}
开发者ID:dieideeistgut,项目名称:rgb-pi-js,代码行数:55,代码来源:Server.ts
示例5: initialize
export function initialize(app: express.Application) {
var env = app.get('env');
app.use(favicon(path.join(config.root, 'public', 'favicon.ico')));
app.use(express.static(path.join(config.root, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(methodOverride('X-HTTP-Method'));
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(cookieParser());
// Persist sessions with mongoStore
// We need to enable sessions for passport twitter because its an oauth 1.0 strategy
app.use(session({
secret: config.secrets.session,
resave: true,
saveUninitialized: true,
store: new mongoStore({ mongoose_connection: mongoose.connection })
}));
app.use(csrf());
app.use(function(req: express.Request, res: express.Response, next: Function) {
res.cookie('XSRF-TOKEN', req.csrfToken());
next();
});
app.use(passport.initialize());
app.use(passport.session());
if ('production' === env) {
app.use(morgan('prod'));
}
if ('development' === env || 'test' === env) {
app.use(morgan('dev'));
}
app.use(errorHandler()); // Error handler - has to be last
};
开发者ID:pgrm,项目名称:logtank,代码行数:38,代码来源:express.ts
示例6: debug
queryParameter: 'lang',
directory: `${ROOT}/src/locales`,
autoReload: isDev,
api: {
'__': 't', // now req.__ becomes req.t
'__n': 'tn' // and req.__n can be called as req.tn
}
});
// Setup Middlewares
app.use(helmet());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(localization.init); // i18n init parses req for language headers, cookies, etc.
app.use(favicon(path.join(srcPath, 'public', 'favicon.ico')));
app.use(express.static(path.join(srcPath, 'public')));
if (isDev) {
app.use(morgan('dev'));
}
// Pass translation function to templates
app.use((req: CustomInterfaces.CustomRequest, res: CustomInterfaces.CustomResponse, next: Function) : void => {
debug('Passing translation functions to templates');
env.addGlobal('translate', req.t);
env.addGlobal('pluralTranslate', req.tn);
next();
});
// Add the logger middleware so we can capture data automatically
开发者ID:melxx001,项目名称:simple-nodejs-typescript-starter,代码行数:31,代码来源:server.ts
示例7: CustomError
import CustomError = objects.CustomError;
var myerror = new CustomError();
var routes = require('./routes/index');
var users = require('./routes/users');
var survey = require('./routes/survey');
var answer = require('./routes/answer');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// uncomment after placing your favicon in /public
app.use(favicon(path.join(__dirname, '../public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
// Initialize Session
app.use(session({
secret: 'someSecret',
saveUninitialized: false,
resave: true
}));
app.use(passport.initialize());
app.use(passport.session());
// Initialize Flash Messages
开发者ID:p1brighto,项目名称:simple-survey,代码行数:31,代码来源:app.ts
示例8: function
next();
});*/
mongoose.connect('mongodb://localhost:27017/registration');
var db = mongoose.connection;
db.on("error", console.error.bind(console,'connection error:'));
db.once('open',function() {
console.log("DB Connection steht");
});
app.use(favicon(__dirname + '/favicon.ico'));
//statische Pfade auf Ordnerstrukturen auf dem Server
app.use('/app', express.static("./app"));
app.use('/node_modules', express.static("./node_modules"));
app.use('/uploads', express.static("./uploads"));
app.use('/uploads/groups', express.static("./uploads/groups"));
app.use('/uploads2', express.static("./uploads"));
var router = express.Router();
app.use(router);
/*var whitelist = ['http://ia.media-imdb.com', 'http://46.101.97.0'];
var corsOptionsDelegate = function(req, callback){
var corsOptions;
开发者ID:SocialMovieNetwork,项目名称:SMP-Finaler,代码行数:31,代码来源:server.ts
示例9: initalize
// start express application
public initalize(app: any, config: ConfigType) {
this.app = app;
this.config = config;
// view engine setup
app.set('views', path.join(config.root, 'views'));
app.set('view engine', 'ejs');
// validator
app.use(expressValidator());
// favicon
app.use(favicon(path.join(config.root, '.', 'public', 'favicon.ico'))); // uncomment after placing your favicon in /public
// logger
app.use(logger('dev'));
// bodyParser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// cookieParser
app.use(cookieParser());
// session
app.use(session({
secret: config.session.secret,
resave: config.session.resave,
saveUninitialized: config.session.saveUninitialized,
cookie: { maxAge: config.session.cookie.maxAge }
}));
// public folder path
const cacheTime = 10000; // 10s
app.use(express.static(path.join(config.root, '.', 'public'), {
maxAge: cacheTime,
lastModified: true,
redirect: true }
));
// Sample cache of extension match
// app.use(function (req, res, next) {
// if (req.url.match(/^\/(css|js|img|font)\/.+/)) {
// res.setHeader('Cache-Control', 'public, max-age=3600');
// }
// next();
// });
// Initialize connect-flash
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
// Setup auth
let auth = glob.sync(config.root + '/middlewares/*.+(js|ts|jsx|tsx)');
auth.forEach(function (routes) {
require(routes)(app);
});
// require(__dirname + '/middlewares/passport')(app);
// Setup routes
let routes = glob.sync(__dirname + '/routes/*.+(js|ts|jsx|tsx)');
routes.forEach(function (routes) {
require(routes)(app);
});
// require(__dirname + '/routes/about')(app);
// require(__dirname + '/routes/api')(app);
// require(__dirname + '/routes/hello')(app);
// require(__dirname + '/routes/index')(app);
// require(__dirname + '/routes/material')(app);
// require(__dirname + '/routes/member')(app);
// require(__dirname + '/routes/redux')(app);
// require(__dirname + '/routes/simple')(app);
// catch 404 and forward to error handler
app.use((req: any, res: any, next: any) => {
let err: any = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use((err: any, req: any, res: any, next: any) => {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
//.........这里部分代码省略.........
开发者ID:toannvbk93,项目名称:goemon,代码行数:101,代码来源:app-server.ts
示例10: require
// setup socket.io object
var favicon = require('serve-favicon');
var bodyParser = require('body-parser')
var server = express();
var httpServer = require('http').Server(server);
var cm = new cc.ConnectionManager(httpServer);
var messageBus = new MessageBus.MessageBusService();
var config = new ConfigurationService('./configuration.json');
// all environments
var port = "3002";
server.set('port', port);
server.use(favicon(__dirname + '/public/favicon.ico'));
server.use(bodyParser.json()); // support json encoded bodies
server.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
config.add("server", "http://localhost:" + port);
var pr = new DynamicProject.DynamicProjectService(server,cm,messageBus);
pr.Start(server);
// var planes = new fr.FlightRadar(cm, "FlightRadar");
// planes.Start();
// server.get("/fr", planes.GetLayer);
var ds = new DataSource.DataSourceService(cm,"DataSource");
ds.Start();
server.get("/datasource", ds.GetDataSource);
开发者ID:Maartenvm,项目名称:csWeb,代码行数:30,代码来源:server.ts
注:本文中的serve-favicon.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论