initial commit, boilerplate stuff
This commit is contained in:
16
api/lib/static.ts
Normal file
16
api/lib/static.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Context, Next } from "@oak/oak";
|
||||
|
||||
export default function routeStaticFilesFrom(staticPaths: string[]) {
|
||||
return async (context: Context<Record<string, object>>, next: Next) => {
|
||||
for (const path of staticPaths) {
|
||||
try {
|
||||
await context.send({ root: path, index: "index.html" });
|
||||
return;
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
await next();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user