本文整理汇总了TypeScript中next类的典型用法代码示例。如果您正苦于以下问题:TypeScript next类的具体用法?TypeScript next怎么用?TypeScript next使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了next类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor() {
this.appPath = resolve(`${__dirname}/../app`); // path to next.js project (with the pages dir)
this.nextApp = next({
dir: this.appPath,
dev: process.env.NODE_ENV !== 'production'
});
this.expressApp = express();
this.setRoutes();
}
开发者ID:benangmerah,项目名称:benangmerah,代码行数:11,代码来源:Server.ts
示例2: parseInt
import micro from 'micro'
import { parse } from 'url'
import * as next from 'next'
import backend from '@epic/backend'
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const server = micro(async (req, res) => {
const parsedUrl = parse(req.url, true)
const maybeBackend = await backend(dev, req, res, parsedUrl)
if (maybeBackend) {
return maybeBackend
}
return handle(req, res, parsedUrl)
})
app.prepare().then(() => {
server.listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
开发者ID:stipsan,项目名称:epic,代码行数:28,代码来源:server.ts
示例3: next
// TODO: Convert the custom server implementation to typescript.
import * as compression from 'compression';
import * as express from 'express';
import * as next from 'next';
import { parse } from 'url';
import routes from './routes';
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dir: 'src', dev });
app.prepare().then(() => {
const server = express();
if (process.env.NODE_ENV === 'production') {
// Add gzip compression.
server.use(compression());
}
// Catch any requests to static files not served by next.
server.use(/^(?!\/_next)(.*)\.(.*)/, (req, res) => {
app.render404(req, res, parse(req.url, true));
});
server.use(routes.getRequestHandler(app));
server.listen(process.env.PORT);
});
开发者ID:fubhy,项目名称:drupal-decoupled-app,代码行数:28,代码来源:index.ts
示例4: Next
import * as Koa from 'koa';
import * as Router from 'koa-router';
import * as Next from 'next';
import routes from './routes';
const port = 3000;
const dev = process.env.NODE_DEV !== 'production';
const app = Next({ dev, quiet: true });
const handle = routes.getRequestHandler(app);
app.prepare().then(() => {
const server = new Koa();
const router = new Router();
router.get('*', async ctx => {
await handle(ctx.req, ctx.res);
ctx.respond = false;
});
server.use(async (ctx, next) => {
ctx.res.statusCode = 200;
await next();
});
server.use(router.routes());
server.listen(port);
});
开发者ID:Ushinji,项目名称:next_sample,代码行数:30,代码来源:server.ts
注:本文中的next类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论