25 lines
630 B
TypeScript
25 lines
630 B
TypeScript
|
|
import { CGGService } from 'cgg/Application.ts';
|
|
import { Router, send } from 'oak';
|
|
|
|
const app = new CGGService({ prefix: '/' });
|
|
|
|
// app.route(new Router()
|
|
// .get('/', ctx => ctx.response.body = 'warstone-web service')
|
|
// );
|
|
const ROOT_DIR = "./public/testdata", ROOT_DIR_PATH = "/public";
|
|
|
|
app.use(async (ctx, next) => {
|
|
if (!ctx.request.url.pathname.startsWith(ROOT_DIR_PATH)) {
|
|
next();
|
|
return;
|
|
}
|
|
const filePath = ctx.request.url.pathname.replace(ROOT_DIR_PATH, "");
|
|
await send(ctx, filePath, {
|
|
root: ROOT_DIR,
|
|
});
|
|
});
|
|
|
|
app.start();
|
|
console.log('warstone-web service running on ' + Deno.args.at(0));
|