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


TypeScript express.default函数代码示例

本文整理汇总了TypeScript中express.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: function

module.exports = function () {
    var app = express();
    require('../app/routes/index.server.routes.js')(app);
    return app;
//};
//var morgan = require('morgan');
//var compress = require('compression');
//var bodyParser = require('body-parser');
//var methodOverride = require('method-override');
//module.exports = function () {
//    var app = express();
//    if (process.env.NODE_ENV === 'development') {
//        app.use(morgan('dev'));
//    } else if (process.env.NODE_ENV === 'production') {
//        app.use(compress());
//    }
//    app.use(bodyParser.urlencoded({
//        extended: true
//    }));
//    app.use(bodyParser.json());
//    app.use(methodOverride());

//    app.set('views', './app/views');
//    app.set('view engine', 'ejs');

//    require('../app/routes/index.server.routes.js')(app);
//    return app;
};
开发者ID:vladiko,项目名称:meanStudy,代码行数:28,代码来源:express.ts

示例3: function

module.exports = function(ROOT) {
  var app = express();
  var {ng2engine} = require('angular2-universal-preview');
  // rendering engine

  app.engine('ng2.html', ng2engine);
  app.set('views', path.join(ROOT, 'examples'));
  app.set('view engine', 'ng2.html');
  app.set('view options', { doctype: 'html' });

  var routes = require('./routes');
  var api = require('./api');
  var graphApi = require('./graph_api');


  app.use(serveStatic(`${ROOT}/dist`));
  app.use(serveStatic(`${ROOT}/examples/app/public`));

  app.use('/api', api(ROOT));
  app.use('/graph_api', api(ROOT));
  app.use(routes(ROOT));


  app.use(morgan('dev'));

  app.get('*', function(req, res) {
    res.json({
      'route': 'Sorry this page does not exist!'
    });
  });

  return app;
};
开发者ID:JoshAntBrown,项目名称:universal,代码行数:33,代码来源:server.ts

示例4: Promise

export const start = async (port: string) => {
  await MongooseClient.InitMongoConnection();

  const app = express();
  const appRootUrl = siteName ? `https://${siteName}.azurewebsites.net` : `http://localhost:${port}`;

  initPassport(appRootUrl);
  enableSessions(app, SocketServer);
  initSockets();
  app.use(json())
  app.use(passport.initialize());
  app.use(passport.session());
  const server = createServer(app);
  SocketServer.attach(server);

  app.use(Routes);

  await new Promise(resolve => {
    server.listen(port, () => {
      console.log(`Server listening at port ${port}`);
      resolve()
    });
  })

  return async function close() {
    await new Promise(resolve => server.close(resolve))
    await MongooseClient.disconnect()
  }
};
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:29,代码来源:app.ts

示例5: require

	constructor(bot:any, config:any) {
		this.name = 'webserver';
		this.title = 'Webserver';
		this.description = "Webserver module for Modubot";
		this.version = '0.1';
		this.author = 'Kamal Nasser';

		this.bot = bot;
		this.database = bot.database;
		this.client = bot.client;
		this.commands = {};
		this.config = config;
		this.plugins = [];

		var express = require('express');
		this.port = this.config.port || 8888;

		this.server = express();
		this.server.use(express.static(__dirname + '/public'));
		this.server.set('views', __dirname + '/views');
		this.server.set('view engine', 'jade');
		this.server.locals.bot = this.bot;
		this.server.locals.plugins = this.plugins;

		if(this.server.listen(this.port)){
			console.log('Webserver listening on port http://localhost:' + this.port);
		} else {
			console.log('Error binding to port ' + this.port);
		}

		this.setupRoutes();
		this.loadPlugins();
	}
开发者ID:reynir,项目名称:Modubot.js,代码行数:33,代码来源:webserver.ts

示例6: Promise

test('downloadStream() for media', async t => {
  const app = express()
  app.use(require('cookie-parser')())
  app.get('/ding', function(req, res) {
    // console.log(req.cookies)
    t.ok(req.cookies, 'should has cookies in req')
    t.is(req.cookies.life, '42', 'should has a cookie named life value 42')
    res.end('dong')
  })

  const server = http.createServer(app)
  server.on('clientError', (err, socket) => {
    t.fail('server on clientError' + err)
    socket.end('HTTP/1.1 400 Bad Request\r\n\r\n')
  })
  server.listen(65534)

  try {
    const s = await Misc.urlStream('http://127.0.0.1:65534/ding', [{name: 'life', value: 42}])
    await new Promise((resolve, reject) => {
      s.on('data', (chunk) => {
        // console.log(`BODY: ${chunk}`)
        t.is(chunk.toString(), 'dong', 'should success download dong from downloadStream()')
        server.close()
        resolve()
      })
      s.on('error', reject)
    })
  } catch (e) {
    t.fail('downloadStream() exception: ' + e.message)
  }
})
开发者ID:miggame,项目名称:wechaty,代码行数:32,代码来源:misc.spec.ts

示例7: function

module.exports = function(ROOT) {
  var app = express();
  var {expressEngine} = require('angular2-universal-preview');
  // rendering engine
  app.engine('ng2.html', expressEngine);
  app.set('views', path.join(ROOT));
  app.set('view engine', 'ng2.html');
  app.set('view options', { doctype: 'html' });
  app.set('json spaces', 2);

  var routes = require('./routes');
  var api = require('./api');
  var graphApi = require('./graph_api');

  app.use(serveStatic(path.join(ROOT, 'dist'), {index: false}));
  app.use(serveStatic(path.join(ROOT, 'public'), {index: false}));

  app.use('/api', api(ROOT));
  app.use('/graph_api', api(ROOT));
  app.use(routes(ROOT));


  app.use(morgan('dev'));

  app.get('*', function(req, res) {
    res.json({
      'url': req.originalUrl,
      'route': 'Sorry this page does not exist!'
    });
  });

  return app;
};
开发者ID:justindujardin,项目名称:universal,代码行数:33,代码来源:server.ts

示例8: listen

  // Listen takes the same arguments as http.Server.listen.
  public async listen(...opts: Array<any>): Promise<ServerInfo> {
    // This class is the easy mode for people who don't create their own express
    // object, so we have to create it.
    const app = express();

    // provide generous values for the getting started experience
    super.applyMiddleware({
      app,
      path: '/',
      bodyParserConfig: { limit: '50mb' },
      cors:
        typeof this.cors !== 'undefined'
          ? this.cors
          : {
              origin: '*',
            },
    });

    const httpServer = http.createServer(app);
    this.httpServer = httpServer;

    if (this.subscriptionServerOptions) {
      this.installSubscriptionHandlers(httpServer);
    }

    await new Promise(resolve => {
      httpServer.once('listening', resolve);
      // If the user passed a callback to listen, it'll get called in addition
      // to our resolver. They won't have the ability to get the ServerInfo
      // object unless they use our Promise, though.
      httpServer.listen(...(opts.length ? opts : [{ port: 4000 }]));
    });

    return this.createServerInfo(httpServer, this.subscriptionsPath);
  }
开发者ID:apollostack,项目名称:apollo-server,代码行数:36,代码来源:index.ts

示例9: require

(function () {
    "use strict";
    var express = require('express');
    var routes = require('./routes');

    var app = express();

    app.configure(function () {
        app.use(express.bodyParser());
        app.use(express.static(__dirname + '/public'));

        app.get('/api/todo', routes.getallTodoes);        
        app.get('/api/todo/MetaData', routes.getMetadata);
        app.get('/api/todo/:todoid', routes.getTodoById);
        app.post('/api/todo', routes.saveChanges);

        app.get('/api/faketodo', routes.getallFakeTodoes);
        app.get('/api/faketodo/MetaData', routes.getFakeMetaData);
        app.get('/api/faketodo/:todoid', routes.getFakeTodoById);
        app.post('/api/faketodo', routes.saveFakeChanges);

    });
    console.log('listing on port::' + process.env.PORT);
    app.listen(process.env.PORT || 9000);

})();
开发者ID:latticework,项目名称:proto-ng-breeze-edge,代码行数:26,代码来源:server.ts

示例10: constructor

        constructor() {

            var express = require('express'),
                logger = require('morgan'),
                session = require('express-session')

            var Grant = require('grant-express'),
                grant = new Grant(require('./server/OAuthConfigure.json'))

            var app = express()
            app.use(logger('dev'))

            // REQUIRED:
            app.use(session({
                    secret: 'very secret'
                }))
                // mount grant
            app.use(grant)

            app.get('/handle_visualstudio_callback', function(req, res) {
                console.log(req.query)
                res.end(JSON.stringify(req.query, null, 2))
            });

            this.setupHttpServer(app);
        }
开发者ID:nimatra,项目名称:vsaddin,代码行数:26,代码来源:server.ts


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