当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript serve-favicon类代码示例

本文整理汇总了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')));







开发者ID:VietAnhh,项目名称:twilio-angular2,代码行数:23,代码来源:app.ts

示例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')));
开发者ID:PhyrionX,项目名称:MiPaginaPersonal,代码行数:30,代码来源:app.ts

示例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))
    })
  }
})
开发者ID:xavdid,项目名称:kerfuffle,代码行数:30,代码来源:index.ts

示例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);
});
开发者ID:bensbigolbeard,项目名称:universal-todomvc,代码行数:30,代码来源:server.ts

示例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);
开发者ID:tanchifu,项目名称:node-express-boilerplate,代码行数:31,代码来源:app.ts

示例6: default

export default (publicDir: string) => {
    return serveFavicon(publicDir + '/favicon.png');
};
开发者ID:lovett,项目名称:notifier,代码行数:3,代码来源:favicon.ts

示例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;
开发者ID:brunolm,项目名称:ts-react-redux-startup,代码行数:30,代码来源:app.ts

示例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);
开发者ID:Cyberdada,项目名称:adv1,代码行数:31,代码来源:app.ts


注:本文中的serve-favicon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。