本文整理匯總了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) => {
示例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;
示例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);
};
示例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));
}
示例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
};
示例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
示例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
示例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;
示例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
//.........這裏部分代碼省略.........
示例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);