本文整理汇总了TypeScript中koa-mount类的典型用法代码示例。如果您正苦于以下问题:TypeScript koa-mount类的具体用法?TypeScript koa-mount怎么用?TypeScript koa-mount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了koa-mount类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: Koa
import * as Koa from "koa";
import * as mount from "koa-mount";
const a = new Koa();
a.use((next) => {
this.body = "Hello";
});
const b = new Koa();
b.use((next) => {
this.body = "World";
});
const app = new Koa();
app.use(mount("/hello", a));
app.use(mount("/world", b));
app.listen(3000);
console.log("listening on port 3000");
开发者ID:DavidM77,项目名称:DefinitelyTyped,代码行数:22,代码来源:koa-mount-tests.ts
示例2: Koa
"use strict";
import * as Koa from "koa";
import * as mount from "koa-mount";
import * as serve from "koa-static";
import { join } from "path";
import server from "./server/server";
const app = new Koa();
app.use(mount(server));
app.use(mount("/app", serve(join(__dirname, "client/build"))));
export default app;
开发者ID:coderfox,项目名称:Another-SS-Panel,代码行数:15,代码来源:index.ts
示例3: webpackServeWaitpage
add: (app, middleware, options) => {
app.use(
webpackServeWaitpage(options, {
template: fs.readFileSync(
path.join(config.paths.gitRoot, 'webpack', 'config', 'waitpage.ejs'),
'utf8'
)
})
)
app.use(mount('/node_modules', serve(config.paths.nodeModules)))
app.use(
mount('/currencies', serve(path.join(config.paths.vendor, 'game-currency-formats', 'src')))
)
// Make sure the usage of webpack-serve-waitpage will be before the following commands if exists
middleware.webpack()
middleware.content()
app.use(router.routes())
}
开发者ID:borestad,项目名称:playground,代码行数:22,代码来源:config.webpack.serve.ts
示例4: serveStatic
export function serveStatic(): Koa.Middleware {
const middlewares: Array<Koa.Middleware> = [];
const distPublicPath = path.resolve(__dirname, '../public');
middlewares.push(mount('/dist/public', serve(distPublicPath)));
middlewares.push(favicon(path.resolve(distPublicPath, 'images', 'icons', 'favicon.ico')));
if (!isProdEnv) {
const publicPath = path.resolve(__dirname, '../../public');
middlewares.push(mount('/public', serve(publicPath)));
const nodeModulesPath = path.resolve(__dirname, '../../node_modules');
middlewares.push(mount('/node_modules', serve(nodeModulesPath)));
}
middlewares.push(async (ctx: Koa.Context, next: () => Promise<any>) => {
const url = ctx.originalUrl;
if (url.substr(0, 6) === '/dist/'
|| url.substr(0, 14) === '/node_modules/'
|| url.substr(0, 8) === '/public/') {
ctx.status = 404;
} else {
await next();
}
});
return compose(middlewares);
}
开发者ID:giggio,项目名称:transempregos-portal,代码行数:23,代码来源:staticFiles.ts
示例5: initialize
export function initialize() {
const httpServer = http.createServer(app.callback())
log('Starting HTTP server')
// We serve the root of the application at the moment
app.use(mount('/', serveRoot()))
// Renders the main html wrapper for the index
app.use(context => {
context.body = '<!DOCTYPE html>' + renderToString(createElement(HTMLPage))
})
websocket.initialize(httpServer)
httpServer.listen(3000)
}
开发者ID:Edward-Lombe,项目名称:elm-electron,代码行数:21,代码来源:server.ts
示例6: Error
neq: function fnb(this: any, lvalue: any, rvalue: any, options: any) {
if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
}
if (lvalue !== rvalue) {
return options.fn(this);
} else {
return options.inverse(this);
}
},
},
},
})
);
// TODO: logger
app.use(bodyParser());
app.use(
session({
store: new sessionStore(dbPath),
})
);
app.use(
mount("/js", serve(`${__dirname}/../node_modules/material-design-lite/dist`))
);
app.use(
mount("/css", serve(`${__dirname}/../node_modules/material-design-lite/dist`))
);
app.use(router.routes()).use(router.allowedMethods());
export default app;
开发者ID:coderfox,项目名称:Another-SS-Panel,代码行数:30,代码来源:server.ts
示例7: next
// Compress response
app.use(compress({
flush: zlib.constants.Z_SYNC_FLUSH
}));
// HSTS
// 6months (15552000sec)
if (config.url.startsWith('https')) {
app.use(async (ctx, next) => {
ctx.set('strict-transport-security', 'max-age=15552000; preload');
await next();
});
}
app.use(mount('/api', require('./api')));
app.use(mount('/files', require('./file')));
// Init router
const router = new Router();
// Routing
router.use(activityPub.routes());
router.use(webFinger.routes());
// Register router
app.use(router.routes());
app.use(mount(require('./web')));
function createServer() {
开发者ID:ha-dai,项目名称:Misskey,代码行数:30,代码来源:index.ts
示例8: mount
protected mount() {
this.app.use(_mount(this.mount_path, this.router.middleware()));
}
开发者ID:HackrLabs,项目名称:HakrPass,代码行数:3,代码来源:base-handler.ts
注:本文中的koa-mount类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论