Support compiling static assets, add compile task
This commit is contained in:
parent
cea96e170d
commit
2ac3180c0f
@ -1,7 +1,8 @@
|
||||
{
|
||||
"tasks": {
|
||||
"dev": "deno run --allow-all --watch server.ts",
|
||||
"server": "deno run --allow-all server.ts"
|
||||
"server": "deno run --allow-all server.ts",
|
||||
"compile": "deno compile --allow-all --include ./assets/ --output substr server.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@deno/gfm": "jsr:@deno/gfm@^0.9.0",
|
||||
|
@ -85,6 +85,7 @@ router.get("/:username/:identifier", async (ctx) => {
|
||||
});
|
||||
|
||||
router.get("/assets/:path*", async (ctx) => {
|
||||
console.log(import.meta.dirname);
|
||||
try {
|
||||
let filePath = ctx.params.path || "";
|
||||
let root: string;
|
||||
@ -93,7 +94,7 @@ router.get("/assets/:path*", async (ctx) => {
|
||||
filePath = filePath.replace(/^g\//, "");
|
||||
root = "/tmp/substr";
|
||||
} else {
|
||||
root = `${Deno.cwd()}/assets`;
|
||||
root = `${import.meta.dirname}/assets`;
|
||||
}
|
||||
|
||||
await send(ctx, filePath, { root });
|
||||
|
Loading…
x
Reference in New Issue
Block a user