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

TypeScript serve-static类代码示例

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

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



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

示例1: initializeWatchers

export async function devCommand(config: Config, args) {
  const port = args["x"] || args["port"] || 8000;
  const path = args["p"] || args["path"] || process.cwd();
  const workingDir = await searchForProjectDir(path);
  const servePath = join(workingDir, config.caches.DEPLOY_DIR);
  const lede = loadLede(workingDir, config.logger);
  const logger = config.logger;

  // Dependency instantiation
  const deployer = new lede.deployers.FileSystemDeployer({workingDir: servePath, logger});
  const htmlCompiler = new lede.compilers.NunjucksCompiler(Object.assign({}, config.htmlCompilerArgs, {logger}));
  const styleCompiler = new lede.compilers.SassCompiler(Object.assign({}, config.styleCompilerArgs, { cacheDir: config.caches.COMPILER_CACHE, logger }));
  const scriptCompiler = new lede.compilers.Es6Compiler(Object.assign({}, config.scriptCompilerArgs, { cacheDir: config.caches.COMPILER_CACHE, logger }));
  const projectDirector = new lede.ProjectDirector({ workingDir, depCacheDir: config.caches.DEP_CACHE, deployer, logger, htmlCompiler, scriptCompiler, styleCompiler, debug: true });
  const fileServer = connect();
  const lrServer = livereload.createServer();

  await projectDirector.compile();

  await initializeWatchers({ workingDir, depCacheDir: config.caches.DEP_CACHE, projectDirector});
  fileServer.use(serveStatic(servePath));
  fileServer.listen(port);
  const pageModels = await Promise.all(
    projectDirector.model.pages.map(p => projectDirector.model.getPageTree({name: p.name, debug: true}))
  );
  const livereloadPaths = pageModels.map(p => join(servePath, p.context.$PROJECT.$name, p.context.$PAGE.$name));
  lrServer.watch(livereloadPaths);
  logger.info(`Project ${projectDirector.model.project.name} has finished compiling and is being watched for changes.`);
  for (let page of pageModels) {
    logger.info(`Serving ${page.context.$PAGE.$name} at http://localhost:${port}/${page.context.$PROJECT.$name}/${page.context.$PAGE.$name}`);
  }
  return new Promise((resolve, reject) => {

  });
}
开发者ID:tbtimes,项目名称:lede-cli,代码行数:35,代码来源:dev.ts


示例2: protractor

function protractor(callback, args, testId: string) {
  const buildConfig = require('../../build/config');
  const app = connect().use(serveStatic(PROJECT_ROOT));
  const protractorHttpServer = createServer(app).listen(buildConfig.protractorPort);

  console.log(`Serving ${process.cwd()} on http://localhost:${buildConfig.protractorPort}`);

  const child = spawn('protractor', args, {
    stdio: [process.stdin, process.stdout, 'pipe']
  });

  let errored = false;
  let callbackCalled = false;

  child.stderr.on('data', function(data) {
    protractorHttpServer.close();
    console.error(data.toString());
    if (!errored) {
      errored = true;
      if (!callbackCalled) {
        callback('Protractor tests failed.');
        callbackCalled = true;
      }
    }
  });

  child.on('exit', function() {
    protractorHttpServer.close();
    if (!callbackCalled) {
      console.log(`[snapshot] TestId: ${testId}`);
      callback();
      callbackCalled = true;
    }
  });
}
开发者ID:JackMj,项目名称:ionic,代码行数:35,代码来源:snapshot.ts


示例3: serveDocs

export function serveDocs() {
  let server = express();

   server.use(
    APP_BASE,
    serveStatic(resolve(process.cwd()))
  );
}
开发者ID:jtborst,项目名称:instaMoneyDashboard,代码行数:8,代码来源:server.ts


示例4: serveCoverage

export function serveCoverage() {
  let server = express();

  server.use(
    APP_BASE,
    serveStatic(resolve(process.cwd(), 'coverage'))
  );

  server.listen(COVERAGE_PORT, () =>
    openResource('http://localhost:' + COVERAGE_PORT + APP_BASE)
  );
}
开发者ID:Amoghavarsha,项目名称:angular2-seed,代码行数:12,代码来源:server.ts


示例5: serveProd

export function serveProd() {
  let root = resolve(process.cwd(), PROD_DEST);
  let server = express();

  server.use(APP_BASE, serveStatic(root));

  server.use(fallback('index.html', { root }));

  server.listen(PORT, () =>
    openResource('http://localhost:' + PORT + APP_BASE)
  );
};
开发者ID:Amoghavarsha,项目名称:angular2-seed,代码行数:12,代码来源:server.ts


示例6: serveDocs

export function serveDocs() {
  let server = express();

   server.use(
    APP_BASE,
    serveStatic(resolve(process.cwd(), DOCS_DEST))
  );

   server.listen(DOCS_PORT, () =>
    openResource('http://localhost:' + DOCS_PORT + APP_BASE)
  );
}
开发者ID:Georotzen,项目名称:angular2-sdk,代码行数:12,代码来源:server.ts


示例7: Promise

const start = (dir: string): Promise<void> => {
  const serve = serveStatic(dir);
  const server = http.createServer((req: any, res: any) => {
    serve(req, res, finalHandler(req, res));
  });
  const portString = process.env.PORT;
  const port = typeof portString === 'undefined'
    ? 80 : parseInt(portString, 10);
  server.listen(port);
  return new Promise((resolve) => {
    server.on('close', () => resolve());
  });
};
开发者ID:bouzuya,项目名称:kraken,代码行数:13,代码来源:start.ts


示例8: serveProd

export function serveProd() {
  let root = resolve(process.cwd(), Config.PROD_DEST);
  let server = express();
  let compression = require('compression');
      server.use(compression());

  server.use(Config.APP_BASE, serveStatic(root));

  server.use(fallback('index.html', { root }));

  server.listen(Config.PORT, () =>
    openResource('http://localhost:' + Config.PORT + Config.APP_BASE)
  );
};
开发者ID:aliothbl,项目名称:latour-tec,代码行数:14,代码来源:server.ts


示例9: serveCoverage

export function serveCoverage() {
  let server = express();
  let compression = require('compression');
      server.use(compression());

  server.use(
    Config.APP_BASE,
    serveStatic(resolve(process.cwd(), 'coverage'))
  );

  server.listen(Config.COVERAGE_PORT, () =>
    openResource('http://localhost:' + Config.COVERAGE_PORT + Config.APP_BASE)
  );
}
开发者ID:aliothbl,项目名称:latour-tec,代码行数:14,代码来源:server.ts


示例10: routes

    /**
     * Configure routes
     *
     * @class Server
     * @method routes
     * @return void
     */
    private routes(): void {
        let router: express.Router;
        router = express.Router();

        // Static assets
        this.app.use('/assets', serveStatic(path.resolve(this.root, 'assets')));

        // Set router to serve index.html (e.g. single page app)
        router.get('/', (request: express.Request, result: express.Response) => {
            result.sendFile(path.join(this.root, '/index.html'));
        });

        // Set app to use router as the default route
        this.app.use('*', router);
    }
开发者ID:nawalgupta,项目名称:angular2-socketio-chat-example,代码行数:22,代码来源:app.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript sharp类代码示例发布时间:2022-05-28
下一篇:
TypeScript serve-favicon类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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