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


TypeScript serve-static.default函数代码示例

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


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

示例1: registerView

        registerView() {
            // all environments
            this.app.set('port', HTTP_PORT);
            this.app.set('view engine', 'ejs');
            this.app.use('/static', serveStatic(__dirname + '/../static'));
            this.app.use(serveStatic(__dirname + '/../publish'));
            this.app.use(serveStatic(__dirname + '/../lib'));
            // http://stackoverflow.com/questions/12488930/dump-an-object-in-ejs-templates-from-express3-x-views
            this.app.locals.inspect = require('util').inspect;


            this.app.get('/', (req, res) => {
                res.render('pages/index');
            });

            this.app.get('/game', (req, res) => {
                res.render('pages/game');
            });
            this.app.get('/single', (req, res) => {
                res.render('pages/single');
            });

            this.app.get('/admin', (req, res) => {
                res.render('pages/admin', {
                    world: this.world,
                    connMgr: this.connMgr,
                    helper: new AdminHelper()
                });
            });
        }
开发者ID:if1live,项目名称:kisaragi,代码行数:30,代码来源:server_main.ts

示例2: 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

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

示例4: 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

示例5: start

export function start(port?:number,plugins?:Array<any>):void
{
    var httpPort = port;

    if(!httpPort || httpPort === 0)
    {
        httpPort = 3000;
    }

    var app = connect();

    if(plugins)
    {
        plugins.forEach((plugin)=>{
            app.use(plugin);
        })
    }


    if(env === "development")
    {
        app.use(serveStatic(staticPath,{'index': ['src/client/index.html']}))
    }
    else
    {
        staticPath = path.resolve("./dist/src/client");
        app.use(serveStatic(staticPath))
    }

    server = http.createServer(app).listen(httpPort);


    // Maintain a hash of all connected sockets
    var sockets = {}, nextSocketId = 0;
    server.on('connection', function (socket) {
        // Add a newly connected socket
        var socketId = nextSocketId++;
        sockets[socketId] = socket;

        // Remove the socket when it closes
        socket.on('close', function () {
            delete sockets[socketId];
        });
    });

    console.log("Server started");

    return server;
}
开发者ID:coolchem,项目名称:TODORama-advanced,代码行数:49,代码来源:server.ts

示例6: setPageRoutes

export function setPageRoutes(app: express.Application): void {
  // Sets up the favicon
  app.use(favicon(config.server.staticFolder + '/favicon.ico'));
  // First looks for a static file: index.html, css, images, etc.
  app.use(config.server.staticUrl, compress());
  app.use(config.server.staticUrl, static(config.server.staticFolder));
  app.use(config.server.staticUrl, (req: express.Request, res: express.Response, next: (err?: any) => void) => {
    res.send(404);
  });
}
开发者ID:uievolutionkk,项目名称:jsonrpc-mock-server,代码行数:10,代码来源:app.ts

示例7: 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));

	
		}
开发者ID:dieideeistgut,项目名称:rgb-pi-js,代码行数:55,代码来源:Server.ts

示例8: showApp

function showApp() {
    var serve = serveStatic(app, {'index': ['index.html', 'index.htm']});

    appServer = http.createServer(function(req, res){
        var done = finalhandler(req, res);
        serve(req, res, done);
    });
    appServer.listen(8888, function () {
        console.log('Serving ' + app + ' on http://localhost:8888')
    })
}
开发者ID:KrupaR,项目名称:meminsight,代码行数:11,代码来源:server.ts

示例9: setupMiddleware

    public setupMiddleware(): server {
      const proxyOptions: ProxyOption = url.parse( 'http://' + this.option.remoteAddr );
      proxyOptions.preserveHost = true;
      proxyOptions.headers = {host: this.option.host};
      this.app.use((req:http.IncomingMessage,res:http.ServerResponse,next:Function)=>{
        this.option.logger.request(req,res);
        next();
      } );

      this.app.use( '/api/recotw', proxy( proxyOptions ) );
      this.app.use( serveStatic( this.option.root ) );
      return this;
    }
开发者ID:RecoTwExplorer,项目名称:recotw-proxy,代码行数:13,代码来源:server.ts

示例10: testBlockMap

function testBlockMap(oldDir: string, newDir: string) {
  const serveStatic = require("serve-static")
  const finalHandler = require("finalhandler")
  const serve = serveStatic(newDir)

  {
    (process as any).resourcesPath = path.join(oldDir, "win-unpacked", "resources")
  }

  const server = createServer((request, response) => {
    serve(request, response, finalHandler(request, response))
  })

  const mockApp = createTestApp("0.0.1")
  jest.mock("electron", () => {
    return {
      app: mockApp,
    }
  }, {virtual: true})

  return new BluebirdPromise((resolve, reject) => {
    server.on("error", reject)

    server!!.listen(0, "127.0.0.1", 16, () => {
      const updater = new NsisUpdater()
      tuneNsisUpdater(updater)
      updater.logger = console
      const doTest = async () => {
        const address = server!!.address()
        updater.updateConfigPath = await writeUpdateConfig<GenericServerOptions>({
          provider: "generic",
          url: `http://${address.address}:${address.port}`,
        })

        await checkResult(updater)
      }

      doTest()
        .then(() => resolve())
        .catch(reject)
    })
  })
    .finally(() => {
      server.close()
    })
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:46,代码来源:differentialUpdateTest.ts


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