An Simple web-framework for Deno and Friends.
MIT License
Bot releases are visible (Hide)
Published by herudi about 1 year ago
[...slug].tsx
.Published by herudi about 1 year ago
feat(lib/file-router): File System Router a`la Nextjs.
// routes/index.ts
import { RequestEvent } from "https://deno.land/x/[email protected]/mod.ts";
export function GET(rev: RequestEvent) {
return "Hello, Home Index";
}
// app.ts
import { nhttp } from "https://deno.land/x/[email protected]/mod.ts";
import { generateRoute } from "https://deno.land/x/[email protected]/lib/file-router.ts";
const app = nhttp();
await generateRoute(app, "routes", (file) => import("./" + file));
app.listen(8000);
Lookup route from dir :
import { getRouteFromDir } from "https://deno.land/x/[email protected]/lib/file-router.ts";
const route = await getRouteFromDir("my_dir");
console.log(route);
Published by herudi about 1 year ago
Published by herudi about 1 year ago
Published by herudi about 1 year ago
Published by herudi about 1 year ago
import yogaHandler from "https://deno.land/x/nhttp/lib/yoga.ts";
import { createSchema, createYoga } from "npm:graphql-yoga";
const yoga = createYoga({
schema: createSchema({...}),
});
app.any("/graphql", yogaHandler(yoga));
import logger from "https://deno.land/x/nhttp/lib/logger.ts";
app.use(logger());
app.get("/", (rev) => {
rev.log("hello log from home");
return "home";
});
// try this will print the errors.
app.get("/noop", (rev) => {
noop();
return "noop";
});
Published by herudi about 1 year ago
Client
as components for interactive.const Home = () => {
return (
<Client src="/assets/js/home.js" id="home">
<h1 id="text">hello world</h1>
</Client>
)
}
client /assets/js/home.js
const root = document.querySelector("#home");
const text = root.querySelector("#text");
text.innerText = "Hello Home";
Published by herudi over 1 year ago
jsdoc
to libs for ease of use.Published by herudi over 1 year ago
rev.body
#27URL
Published by herudi over 1 year ago
Deno.serve
to default http-server (requires Deno 1.35.x or letter).Helmet
.Published by herudi over 1 year ago
rev.newRequest
clone new Request.rev.requestEvent()
invoke self RequestEvent
.Published by herudi over 1 year ago
respondWith
and waitUntil
app.get("/", ({ respondWith }) => {
respondWith(new Response("hello"));
})
Published by herudi over 1 year ago
nhttp()
.engine(...)
.get(...)
.listen(8000);
await
app.listen.const app = nhttp({ flash: true });
// Bad
await app.listen(8000);
// Good
app.listen(8000);
Published by herudi over 1 year ago
http.createServer(app.handle).listen(3000);
options.onRenderElement = (elem, rev) => {...};
Published by herudi over 1 year ago
options.onRenderElement = async (elem) => {...};
options.onRenderHtml = async (html) => {...};
Published by herudi over 1 year ago
app.get("/", () => ({ int: BigInt(9007199254740991) }));
Published by herudi over 1 year ago
multipart
change flag writeFile boolean or function.jsx
add options to render.Published by herudi over 1 year ago
showInfo
flag to app.listen
.storage
function to multipart. to support custom storage like (s3, supabase-storage, gdrive, etc).const upload = multipart.upload({
async storage(file) {
// code
}
});
Published by herudi over 1 year ago
preflight
flag to cors libs.app.get("/", () => {
throw "noop";
// => { status: 500, message: "noop" };
})
Published by herudi over 1 year ago
CORS
.import nhttp from "https://deno.land/x/[email protected]/mod.ts";
import cors from "https://deno.land/x/[email protected]/lib/cors.ts";
const app = nhttp();
app.use(cors());
app.get("/", () => "Hello with cors");
app.listen(8000);
onAuth
in jwt libs.