api #3

Merged
SethTrowbridge merged 7 commits from api into master 2023-07-29 20:30:03 -04:00
9 changed files with 30 additions and 10 deletions
Showing only changes of commit 6cee7ac065 - Show all commits

1
.vscode/launch.json vendored
View File

@ -8,6 +8,7 @@
"request": "launch",
"name": "Debug Serve Mode",
"type": "node",
"cwd": "${workspaceFolder}/example",
"runtimeExecutable": "deno",
"runtimeArgs": ["task", "debug"],
"attachSimplePort": 9229

4
api Normal file
View File

@ -0,0 +1,4 @@
export default (req:Request):Response|false=>
{
return false;
}

View File

View File

@ -1 +0,0 @@
export default ()=>{};

View File

@ -7,12 +7,12 @@
{
"react":"https://esm.sh/preact@10.15.1/compat",
"react-original":"https://esm.sh/preact@10.15.1/compat",
">able/": "https://gitea.hptrow.me/SethTrowbridge/able-baker/raw/branch/master/"
">able/": "http://localhost:4507/"
},
"tasks":
{
"local": "deno run -A --no-lock ./run-local.tsx --port=1234",
"serve": "deno run -A --no-lock ./run-serve.tsx --port=1234",
"debug": "deno run -A --inspect-wait --no-lock ./run-serve.tsx --port=1234"
"local": "deno run -A --reload=http://localhost --no-lock ./run-local.tsx --port=1234",
"serve": "deno run -A --reload=http://localhost --no-lock ./run-serve.tsx --port=1234",
"debug": "deno run -A --reload=http://localhost --inspect-wait --no-lock ./run-serve.tsx --port=1234"
}
}

4
example/api.tsx Normal file
View File

@ -0,0 +1,4 @@
export default (inReq:Request)=>
{
return false;
}

View File

@ -3,12 +3,15 @@
"imports":
{
"react": "https://esm.sh/preact@10.15.1/compat",
">able/app.tsx": "./app.tsx",
">able/": "http://localhost:4507/"
">able/": "http://localhost:4507/",
">able/app": "./app.tsx",
">able/api": "./api.tsx"
},
"tasks":
{
"local": "deno run -A --no-lock --reload=http://localhost:4507/ http://localhost:4507/run-local.tsx",
"serve": "deno run -A --no-lock --reload=http://localhost:4507/ http://localhost:4507/run-serve.tsx"
"local": "deno run --config=deno.json -A --no-lock --reload=http://localhost:4507 http://localhost:4507/run-local.tsx",
"serve": "deno run --config=deno.json -A --no-lock --reload=http://localhost:4507 http://localhost:4507/run-serve.tsx",
"deploy":"deno run -A --no-lock --reload=http://localhost:4507 http://localhost:4507/run-deploy.tsx",
"debug": "deno run --config=deno.json -A --inspect-wait --no-lock --reload=http://localhost:4507 http://localhost:4507/run-serve.tsx"
}
}

View File

@ -67,6 +67,7 @@ try
"run",
"-A",
"--no-lock",
"--config=deno.json",
"https://deno.land/x/deploy/deployctl.ts",
"deploy",
`--project=${useProject}`,

View File

@ -1,6 +1,9 @@
import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts";
import * as SWCW from "https://esm.sh/@swc/wasm-web@1.3.62";
import Api from ">able/api";
export const Root = new URL(`file://${Deno.cwd().replaceAll("\\", "/")}`).toString();
Deno.args.forEach(arg=>
@ -319,7 +322,6 @@ const server = Deno.serve({port:parseInt(Deno.env.get("port")||"8000")}, async(r
}
}
console.log("proxy will be", proxy);
// allow for custom handler
const custom = await Configuration.Serve(req, url, ext, ImportMap, Configuration);
@ -328,6 +330,12 @@ const server = Deno.serve({port:parseInt(Deno.env.get("port")||"8000")}, async(r
return custom;
}
const api = Api(req);
if(api)
{
return api;
}
// transpileable files
if(Transpile.Check(ext))
{