• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript morgan.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中morgan.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: initialize

function initialize() {
    var config = configuration;

    // Configure application settings.  Consult the Express API Reference for a
    // list of the available [settings](http://expressjs.com/api.html#app-settings).

    var viewsDir = path.resolve(config.startupDirectory, "./views");
    var stylesDir = path.resolve(config.startupDirectory, "./styles");
    var publicDir = path.resolve(config.startupDirectory, "./dist/public");

    config.logger.info("Views directory: %s", viewsDir);
    config.logger.info("Styles directory: %s", stylesDir);
    config.logger.info("Public directory: %s", publicDir);

    this.set('views', viewsDir);
    this.set('view engine', 'jade');

    // Register Jade as a template engine.
    this.engine('jade', require('jade').__express);

    // Override default template extension.  By default, Locomotive finds
    // templates using the `name.format.engine` convention, for example
    // `index.html.ejs`  For some template engines, such as Jade, that find
    // layouts using a `layout.engine` notation, this results in mixed conventions
    // that can cuase confusion.  If this occurs, you can map an explicit
    // extension to a format.
    this.format('html', { extension: '.jade' })

  // Register formats for content negotiation.  Using content negotiation,
  // different formats can be served as needed by different clients.  For
  // example, a browser is sent an HTML response, while an API client is sent a
  // JSON or XML response.
  /* this.format('xml', { engine: 'xmlb' }); */

  // Use middleware.  Standard [Connect](http://www.senchalabs.org/connect/)
  // middleware is built-in, with additional [third-party](https://github.com/senchalabs/connect/wiki)
  // middleware available as separate modules.  

    this.use(poweredBy('Locomotive'));
    this.use(morgan());
    //this.use(favicon(path.resolve(publicDir, 'favicon.ico')));
    this.use(cookieParser());

    this.use("/src", express.static(path.resolve(config.startupDirectory, "./src")));
    this.use(express.static(publicDir));

    this.use(bodyParser.json());
    this.use(bodyParser.urlencoded({ extended: true }));
    this.use(methodOverride());

    /* istanbul ignore next */
    config.dataFactory = (): any => { 
        return new GitHubApi ({
            // required
            version: "3.0.0",
            // optional
            debug: false,
            protocol: "https",
            host: "api.github.com",
            timeout: 5000
        });
    };

    config.logger.debug("Common environment init completed");
}
开发者ID:ciuliot,项目名称:github-tracker,代码行数:65,代码来源:all.ts


示例2: winstonMongo

var expressWinston = require('express-winston');
var winstonMongo = require('winston-mongodb').MongoDB;

// my modules
import config = require('./config');

var app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.enable('trust proxy');      // To get real ip

// Setup loggers
// For console, use morgan logger
app.use(logger('combined'));
// express-winston logger makes sense BEFORE the router.
// Send log to mongodb
expressWinston.requestWhitelist.push('ip');
expressWinston.requestWhitelist.push('ips');
app.use(expressWinston.logger({
    transports: [
        new winstonMongo({
            db: config.winston.mongo.dbName,
            collection: config.winston.mongo.accessLogCollName
        })
    ]
}));

// Setup router
app.use('/', require('./route/index'));
开发者ID:overpower-doublej,项目名称:gcm-server-test,代码行数:31,代码来源:app.ts


示例3: require

var http = require('http'),
	express = require('express'),
	morgan = require('morgan'),
	bodyParser = require('body-parser'),
	mongoose = require('mongoose');

/* Mongo start */
mongoose.connect('mongodb://localhost/timeline');
require('./utilities/mongoScheme');

/* App */
var app = express();
app.set('port', process.env.PORT || 3000);
app.use(express.static(__dirname + '/public'));

app.use(morgan('combined'));
app.use(bodyParser.json()); // parse application/json
app.use(bodyParser.urlencoded({ extended: false })); // parse application/x-www-form-urlencoded

/* Routing */
var auth = require('./routes/auth');

app.post('/api/v1/login', auth.login);
app.post('/api/v1/registration', auth.registration);
app.get('/api/v1/profile', auth.check, auth.profile);

var tasks = require('./routes/tasks');

app.get('/api/v1/tasks', auth.check, tasks.list);
app.get('/api/v1/tasks/:id', auth.check, tasks.get);
app.post('/api/v1/tasks', auth.check, tasks.create);
开发者ID:soramusoka,项目名称:timeline-project,代码行数:31,代码来源:runserver.ts


示例4: require

var methodOverride = require('method-override');
var http = require('http');
var util = require('util');

var app = express();
var port = 5000;

var authRouter = require('./app/authentication/linkedin.routes')();

// set third party libraries
app.use(express.static('public'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(methodOverride());
app.use(morgan());
app.use(session({secret: 'library'}));
app.use(passport.initialize());
app.use(passport.session());


// set routes
app.get('/', function(req, res){
    res.send('Hello World');
});

app.use('/auth', authRouter);

// start server
app.listen(port, function(err){
    console.log('running server on port ' + port);
开发者ID:thekj,项目名称:berlin_sandbox,代码行数:31,代码来源:app.ts


示例5: require

let mockservice = require("./routes/mock");

let app = express();

app.use("/client", express.static(path.resolve("./built/client")));
app.use("/node_modules", express.static(path.resolve("./node_modules")));
app.use("/lib", express.static(path.resolve("./public/lib")));
app.use("/images", express.static(path.resolve("./public/images")));

app.engine("ejs", engine);

app.set("views", "./built/client");
app.set("view engine", "ejs");

// uncomment after placing your favicon in /public 
// 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("/mock/*", mockservice);
app.use("/*", routes);

app.listen(9090, function() {
    console.log("server started 9090 ");
});

module.exports = app;
开发者ID:poomugam,项目名称:smart-quiz,代码行数:30,代码来源:server.ts


示例6: constructor

    constructor() {
        var express = require("express");

        var Panel = require('./panel');
        var ComicWebService = require('./ComicWebService');
        var Comic = require('./comic');
        var TranslateWebService = require('./TranslateWebService')

        let path = require('path');
        let favicon = require('serve-favicon');
        let stormpath = require('express-stormpath');
        let logger = require('morgan');
        let cookieParser = require('cookie-parser');
        let bodyParser = require('body-parser');

        var profile = require('./routes/profile');
        var routes = require('./routes/index');
        var app = express();

        // view engine setup
        app.set('views', path.join(__dirname, 'views'));
        app.set('view engine', 'jade');

// 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());
        app.use(express.static(path.join(__dirname, 'public')));

        app.use(stormpath.init(app, {
            postRegistrationHandler: function (account, req, res, next) {
                var api = new UserWebService();
                api.newUser(new User("", [], [], account.customData.userType, account.email), function (error, response, body) {
                    var temp = JSON.parse(body);
                    console.log(temp['_id']);
                    account.customData.mongoUserID = temp["_id"];
                    account.save();
                });
                next();
            },

            // Function is run after someone logs in
            // Checks to see if the user exists in the MongoDB
            postLoginHandler: function (account, req, res, next){

                if(req.user.customData.mongoUserID == undefined){

                    var api = new UserWebService();
                    api.getAUserByEmail(req.user.email, function(error:string, response:string, body:string){

                        if (body.toString() == "null"){
                            api.newUser(new User("", [], [], req.user.customData.userType.toString(), req.user.email.toString()), function(error:string, response:string, body:string){
                                var temp = JSON.parse(body);
                                req.user.customData.mongoUserID = temp["_id"];
                                req.user.save();
                            });

                        }else{

                            var temp = JSON.parse(body);
                            req.user.customData.mongoUserID = temp["_id"];
                            req.user.save();
                        }
                    });

                }

                next();
            },
            client: {
                apiKey: {
                    id: '4F42CDDRB565RJ2LFG9O8IR3F',
                    secret: '3V84FQEqVIQC09AupKMmjNLxSzmXPq0vAlyDA/qgODs',
                },
            },
            application: {
                href: 'https://api.stormpath.com/v1/applications/MCCvNPvyq2KR5cl0x2POL'
            },

            website: true,
            web: {
                login: {
                    enabled: true,
                    nextUri: "/account"
                },
                register: {
                    enabled: true,
                    fields: {
                        givenName: {
                            enabled: true,
                            required: true
                        },
                        surname: {
                            enabled: true,
                            required: true
                        },
                        userType: {
                            enabled: false,
//.........这里部分代码省略.........
开发者ID:tjxn,项目名称:CharBroiled,代码行数:101,代码来源:app.ts


示例7: function

export var init = function() {
  var app = express();
  // Compress content
  app.use(compression({
    threshold: 512
  }));

  // 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(__dirname + '/public/favicon.ico'));
  app.use(morgan('dev', {
    stream:BunyanStream
  }));
  app.use(bodyParser.json({limit: '128mb'}));
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, '../../public'), {maxAge: 0}));
  var mongoStore = new MongoStore({
      mongooseConnection: mongoose.connection,
      clear_interval: 3600
    });
  app.use(session({
    secret: options.sessionSecret,
    saveUninitialized:true,
    resave:true,
    store: mongoStore
  }));
  // Remember Me middleware
  app.use( function (req, res, next) {
    if ( req.method == 'POST' && req.url == '/login' ) {
      if ( req.body.rememberme ) {
        req.session.cookie.maxAge = 90*24*60*60*1000; // Rememeber 'me' for 90 days
      } else {
        req.session.cookie.expires = false;
      }
    }
    next();
  });

  PassportHandler.init(app);

  app.get('/', function(req,res) {
    if (req.isAuthenticated()) {
      res.redirect(options.baseUrl + '/view');
    } else {
      res.redirect(options.baseUrl + '/login');
    }
  });
  app.use('/view', ViewRoute);
  app.use('/service',ServiceRoute);

  ShareJSHandler.init(app, mongoStore);

  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
    res.status(404);
    res.send("404 - "+req.path+" Not Found");
  });

  // error handlers

  // development error handler
  // will print stacktrace
  if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
      res.status(err.status || 500);
      res.render('error', {
        message: err.message,
        error: err
      });
    });
  }

  // production error handler
  // no stacktraces leaked to user
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: {}
    });
  });

  return app;
};
开发者ID:MisterTea,项目名称:TidalWave,代码行数:88,代码来源:app-handler.ts


示例8: require

import { HgtEndpoint } from "./hgt/HgtEndpoint";
import { LinkEndpoint } from "./link/LinkEndpoint";
import { MessageEndpoint } from "./message/MessageEndpoint";
import { GommetteEndpoint } from "./gommette/GommetteEndpoint";

var express         = require('express');
var logger          = require('morgan');
var bodyParser      = require('body-parser');
var expressResource = require('express-resource');
var compression     = require('compression');

console.log("Server is starting ...");

var app = express();

app.use(logger('tiny'));
app.use(bodyParser.json());
app.use(compression());

console.log("Creating routes ...");

app.use(Authentication.authenticateUser);

app.resource('messages', MessageEndpoint);
app.resource('links', LinkEndpoint);
app.resource('scores/hgt/:channel', HgtEndpoint);
app.resource('scores/gommettes', GommetteEndpoint);
app.get('/scores/hgt/:channel/:year', HgtEndpoint.byYear);
app.get('/scores/hgt/:channel/:year/:week', HgtEndpoint.byWeek);
app.get('/scores/gommettes/:year', GommetteEndpoint.byYear);
app.get('/scores/gommettes/:year/:userId', GommetteEndpoint.byYearAndUser);
开发者ID:jlamby,项目名称:nicobot-persistence,代码行数:31,代码来源:main.ts


示例9: knex

import morgan from "morgan";
import { Model } from "objection";

import schema from "./schema";

dotenv.config();

const PORT = process.env.PORT || 3000;

const knx = knex({
    client: "pg",
    connection: process.env.DATABASE_URL,
});

Model.knex(knx);

const graphqlOptions: ExpressGraphQLOptionsFunction = (request) => ({
    context: { request, knex },
    schema,
});

const app = express();

app.use(morgan("dev"));
app.use("/graphql", bodyParser.json(), graphqlExpress(graphqlOptions));

app.use(express.static("public"));

// tslint:disable-next-line:no-console
app.listen(PORT, () => console.log(`Listening on :${PORT}`));
开发者ID:zaeleus,项目名称:lp-api,代码行数:30,代码来源:index.ts


示例10: express

import logger from 'morgan'
import session from 'express-session'
import passport from 'passport'

import router from './router'
import infra  from './infra'

const app = express();

// view engine setup
app.set('views', path.join(__dirname, '..', 'views'));
app.set('view engine', 'pug');

var fs = require('fs');
var stream = fs.createWriteStream('/var/log/express/app.log', { flags: 'a' });
app.use(logger('dev', { stream }));

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, '..', 'public')));

var sess = {
  secret: 'keyboard cat',
  resave: false,
  saveUninitialized: true,
  cookie: { secure: false }
}

if (app.get('env') === 'production') {
  app.set('trust proxy', 1) // trust first proxy
开发者ID:rymizuki,项目名称:site-animechannel,代码行数:31,代码来源:app.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript morgan.token函数代码示例发布时间:2022-05-25
下一篇:
TypeScript moq.ts.Mock类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap