import { rest, route } from "../server/decorators.ts"; import RestResponse from "../server/RestResponse.ts"; import staticHandler from "../server/staticHandler.ts"; import { stream } from "../utils/utils.ts"; import AppRouter from "./AppRouter.ts"; export class StaticRouter extends AppRouter { @rest('GET', '/http-url.js') getHttpUrl() { return stream(`var $_url = "${this.apiUrl}";`); } @route('*') static = staticHandler('static'); @rest('GET', '*') async index() { return new RestResponse() .body((await Deno.open('static/index.html')).readable) .contentType('html'); } public constructor(private apiUrl: string) { super(); } }