本文整理汇总了TypeScript中serve-favicon类的典型用法代码示例。如果您正苦于以下问题:TypeScript serve-favicon类的具体用法?TypeScript serve-favicon怎么用?TypeScript serve-favicon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了serve-favicon类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: express
/// <reference path="../typings/index.d.ts" />
import * as express from "express";
import { join } from "path";
import * as favicon from "serve-favicon";
import { json, urlencoded } from "body-parser";
import { loginRouter } from "./routes/login";
import { protectedRouter } from "./routes/protected";
const app: express.Application = express();
app.disable("x-powered-by");
app.use(favicon(join(__dirname, "../public", "favicon.ico")));
app.use(express.static(join(__dirname, '../public')));
app.use(json());
app.use(urlencoded({ extended: true }));
// api routes
app.use("/api", protectedRouter);
app.use('/client', express.static(join(__dirname, '../client')));
示例2: express
/// <reference path="../typings/index.d.ts" />
import * as express from "express";
import { join } from "path";
import * as favicon from "serve-favicon";
import { json, urlencoded } from "body-parser";
import { loginRouter } from "./routes/login";
import { protectedRouter } from "./routes/protected";
const app: express.Application = express();
app.disable("x-powered-by");
app.use(favicon(join(__dirname, "../client", "favicon.ico")));
app.use(express.static(join(__dirname, '../client')));
app.use(json());
app.use(urlencoded({ extended: true }));
// api routes
app.use("/api", protectedRouter);
app.use("/login", loginRouter);
app.use('/client', express.static(join(__dirname, '../client')));
// error handlers
// development error handler
// will print stacktrace
if (app.get("env") === "development") {
app.use(express.static(join(__dirname, '../node_modules')));
示例3: express
import * as express from 'express'
import * as helmet from 'helmet'
import * as path from 'path'
import * as favicon from 'serve-favicon'
const app = express()
app.use(helmet())
// dotenv is loaded by foreman
import { MediaType, mediaTypes } from './config'
import fetchMethods from './services/airtable'
import fetchDetailMethods from './services/tmdb'
app.use('/static', express.static(path.join(__dirname, '../../public')))
app.use(favicon(path.join(__dirname, '../../public/favicon.ico')))
mediaTypes.map((mt: MediaType) => {
// lists of ids
app.get(`/api/${mt}`, async (req, res) => {
res.json(await fetchMethods[mt]())
})
// tmdb calls, but not for books
if (mt !== 'books') {
app.get(`/api/${mt}/:id`, async (req, res) => {
res.json(await fetchDetailMethods[mt](req.params.id))
})
}
})
示例4: express
import * as React from 'react';
import * as favicon from 'serve-favicon';
import * as ReactEngine from 'react-engine';
import * as bodyParser from 'body-parser';
import * as cookieParser from 'cookie-parser';
import routes from './initiators/server-routes';
let app = express();
const PORT = 3000;
// create the view engine with `react-engine`
let engine = ReactEngine.server.create({
performanceCollector: function(stats) {}
});
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.use(cookieParser()); // for parsing cookies
app.engine('.js', engine);// set the engine
app.set('views', join(__dirname, '/components'));// set the view directory
app.set('view engine', 'js');// set js as the view engine
app.set('view', ReactEngine.expressView);// finally, set the custom view
app.use(express.static(join(__dirname, '/')));// expose public folder as static assets
app.use(favicon(join(__dirname, '/favicon.ico')));// Use the favicon
routes(app);// Initialize the server routes
const server = app.listen(PORT, function() {
console.log('Example app listening at http://localhost:%s', PORT);
});
示例5: next
import * as bodyParser from 'body-parser';
// Modular Route definitions
import * as exampleRoute from './routes/example';
// Error handler service
import { development as DevelopmentErrorHandler, production as ProductionErrorHandler } from './services/errorHandler';
// Main app
const app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public'))); // serve public files
// Register routes (as middleware layer through express.Router())
app.use(exampleRoute);
// catch 404 and forward to error handler
app.use((req: express.Request, res: express.Response, next: Function) => {
let err = new Error('Not Found');
res.status(404);
console.log('catching 404 error');
return next(err);
示例6: default
export default (publicDir: string) => {
return serveFavicon(publicDir + '/favicon.png');
};
示例7: webpack
const compiler = webpack(webpackConfig);
console.log('Using dev-middleware');
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: webpackConfig.output.publicPath,
hot: true,
stats: {
colors: true,
},
watchOptions: {
poll: 300, // docker support
},
}));
app.use(require('webpack-hot-middleware')(compiler));
}
app.use(compression());
app.use(favicon(path.join(__dirname, 'favicon.ico')));
app.use('/static', express.static(path.join(__dirname, 'dist')));
app.set('view engine', 'cshtml');
app.set('views', path.join(__dirname, 'views'));
app.engine('cshtml', vash.renderFile);
export = app;
示例8: require
import mongoose = require('mongoose');
import methodOverride = require("method-override");
import nconf = require('nconf');
import * as dungeon from "./dungeon/dungeon.route";
import * as player from "./player/player.route";
import * as artifact from "./artifact/artifact.route";
import * as room from "./room/room.route";
var app = express();
nconf.argv().env().file({ file: __dirname +'/settings.json' });
// uncomment after placing your favicon in /public
app.use(favicon(__dirname + '/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(methodOverride('_method'));
var lpath = __dirname.substring(0, __dirname.indexOf("server"));
console.log(lpath);
// ALL ROUTES HERE!!!!
app.post( '/api/dungeons', dungeon.save);
app.get( '/api/dungeons', dungeon.load);
app.get( '/api/dungeons/:id', dungeon.loadById);