boywithkeyboard / cheetah Goto Github PK
View Code? Open in Web Editor NEWA framework for the modern web. (NO LONGER MAINTAINED)
Home Page: https://cheetah.mod.land
License: Apache License 2.0
A framework for the modern web. (NO LONGER MAINTAINED)
Home Page: https://cheetah.mod.land
License: Apache License 2.0
I know it's possible to write code like following to version api:
api
.use('/v1', v1Routes)
.use('/v2', v2Routes);
But If I want to implement something like Header versioning or other type like nestjs has https://docs.nestjs.com/techniques/versioning I will have to write some magic extension code (I believe)
Would be cool a) to have global config to specify default version, specify version for one route? configure how versioning is specified/handled
The extension should be based on X4BNet/lists_vpn, fetch the list dynamically and cache it in-memory for 5 minutes.
Would be helpful to make a way to add new routes from custom extension to extend code
Maybe developers could use it to simply add extension like .use(healthcheck())
that would register it's own route /healthcheck
and add some logic before that
For now it's kinda possible to do by adding it to app.routes
Set, but it can be improved to make it as easy as app.routes.add('GET', '/healtcheck, (c) => '๐')
or with .get
/ .post
methods
This might be a good addition for better caching.
You can already define a schema for headers, query, body, & cookies. It'd definitely be a good addition to allow you to define a schema for params.
c.req.blob()
, c.req.buffer()
, c.req.formData()
(extend body validation: z.instanceof(Blob)
etc.)etag
extensionfavicon
extension (respond to /favicon.ico
requests) #126pretty
extension (pretty-print json) #123transform
option to c.req.body()
method #118+ other unscheduled revisions:
.env
file, make debugging easier, & add cheetah dev
command)wrangler
package behind the scenes, type-safe wranger.toml
, etc.)I am trailing this out and attempting to use denoland/deno_kv_oauth as an oauth provider. Seems that I am able to get passed the signIn
leg of the auth_code flow, however I am not able to get a response from the callback
ย
I think in the discord you mentioned that ctx.req.raw
is the underlining request however that seems to not be working so will be trying to look into that.
server.get("/signin", async (ctx) => {
console.log("signIn::before");
const response = await signIn(ctx.req.raw, oauth2Client);
console.log("signIn::after");
ctx.res.redirect(response.headers.get("location")!, Status.Found);
});
server.get("/callback", async (ctx) => {
console.log("callback::before");
const { response } = await handleCallback(ctx.req.raw, oauth2Client);
console.log("callback::after");
ctx.res.redirect(response.headers.get("location")!, Status.Found);
});
and the log is showing
Listening on http://localhost:3000/
signIn::before
signIn::after
callback::before
I need to be able to retrieve failed network requests that fail to pass through Zod's validation.
Right now, it seems to return default 400 BAD REQUEST
responses by default, but I prefer to know why those requests failed, so I can return that data to the browser and display alerts for all their errors, in case they manage to get through the frontend validation somehow.
I'm using zod as a validation middleware before the response is sent. This is my code:
app.put(
//path
"/register",
//validation
{
body: z.object({
username: z.string({
required_error: "Name is required",
invalid_type_error: "Name must be a string",
}).min(6, { message: "Must be 6 or more characters long" }),
email: z.string().email({ message: "Invalid email address" }),
password: z.string({
required_error: "Password is required",
invalid_type_error: "Password must be a string",
}).min(8, { message: "Password must be 8 or more characters long" }),
confirmPassword: z.string({
required_error: "Password confirmation is required",
invalid_type_error: "Password confirmation must be a string",
}).min(8, {
message: "Password confirmation must be 8 or more characters long",
}),
}),
},
// response
async (c) => {
const reqBody = await c.req.body();
console.log("body:", reqBody);
},
);
When an error happens, the response is sent before reaching the response block.
As issue title states implement support for websockets
As described in Discord https://discord.com/channels/1133030354958172250/1133031689648615476/1138412521485770843
It is not possible for now to pass something to request, also from custom extensions like express have their req.user
build.ts has a soon to be deprecated Deno.run
This should be upgraded to Deno.command
Enhance DX when building an API for Cloudflare Workers (install wrangler
package behind the scenes, type-safe wrangler.toml
, etc.).
I have no idea how to work around this, so I'll just leave this issue open until someone comes up with a good solution.
How should we handle the types for environment variables without affecting the cheetah
/Collection
classes?
Add support for serving files from an S3 bucket to the files
extension.
(This might be especially useful on serverless environments such as Deno Deploy!)
cheetah should support trpc out of the box.
Generating the type declarations should be as simple as running deno run -A https://deno.land/x/cheetah/trpc.ts
As of now, the c.waitUntil
method does nothing other than setting a timeout that fires after 1 second. If the logic after the call of this function takes longer than 1 second to execute, the whole benefit of this feature goes to waste.
The method should behave just like in Cloudflare Workers to make migration easier.
This issue is meant as both a roadmap and note regarding the upcoming v1.0 release.
c.env
across runtimes #85I am trying to upgrade a connection to a websocket connection, and according to the Deno documentation, Deno.upgradeWebsocket()
is what I should use. However, ctx.req
is not a standard Request
object, therefore it cannot be used with that method. Is there a way that I can get a standard Request
object?
Demo code:
import cheetah from "https://deno.land/x/[email protected]/mod.ts";
import { serve } from "https://deno.land/[email protected]/http/server.ts";
const app = new cheetah();
app.get("/upgrade", (ctx) => {
Deno.upgradeWebSocket(ctx.req)
})
Add a high-performant server for static files (Cloudflare R2, S3 bucket or local files).
The c.res.cookies
object provides something similar to a Map but for managing cookies in a simple and secure high-level way. It'll also be the replacement for c.res.cookie()
which will be deprecated.c.res.cookie()
will be a shortcut to c.res.cookies.set()
for now.
cheetah v0.4.0 introduced support for plugins.
The following should be offered officially:
cache
(Deno.KV, Redis, Cache API)helmet
(ported from here) #22ratelimit
(in-memory, Redis, Deno.KV, Cloudflare Durable Objects)Please leave a comment below if you are planning to contribute so we can avoid duplicate work.
Now when running deno run -Ar https://deno.land/x/cheetah/setup.ts
you cannot specify name, neither write it before/after being asked about runtime. And we end up with cheetahland-template-deno-basic-6ae3a45
folder that has to be renamed manually
A small DX touch to let developer specify folder name where to place new project
Hi, i'm the maintainer of esm.sh. This project looks promising! i'm trying to learn your code, i found something vary interesting and iโm just wondering can you please share why you choosed jsdevlivr to import npm packages with esm.sh types. i'm not saying you should use esm.sh, jsdevlivr is great! i'm just curious did you try to use esm.sh with trouble or something, if that i can fix/improve.
// @deno-types='https://esm.sh/@sinclair/[email protected]/value' import { Value } from 'https://cdn.jsdelivr.net/npm/@sinclair/[email protected]/value/value.js/+esm'
anyway, thanks for creating this cool project! (and sorry i filed this non-issue issue i did not find the GH discusisions enabled.)
I have this code:
app.get("/", (ctx) => {
ctx.res.header("Content-Type", "text/html");
ctx.res.text(Deno.readTextFileSync("./index.html").replace("$TURNSTILE_SITE_KEY", Deno.env.get("TURNSTILE_SITE_KEY") || ""));
});
It should send a Content-Type: text/html
header, however, it adds another text/plain; charset=utf-8
header. Is this expected behavior?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.