GithubHelp home page GithubHelp logo

boywithkeyboard-archive / cheetah1 Goto Github PK

View Code? Open in Web Editor NEW
194.0 3.0 1.0 1.7 MB

A framework for the modern web. (NO LONGER MAINTAINED)

Home Page: https://cheetah.mod.land

License: Apache License 2.0

TypeScript 100.00%
cheetah deno javascript typescript framework router cloudflare fast cloudflare-workers deno-deploy secure-by-default modern

cheetah1's Introduction



cheetah

🛡️ secure × 💎 simple × 🪶 light


Warning

cheetah is currently not maintained.


Sneak Peek 👾

import cheetah from 'https://deno.land/x/cheetah/mod.ts'
import { z } from 'https://deno.land/x/zod/mod.ts'

const app = new cheetah()
  .post('/', {
    body: z.object({ // < scheme validation
      name: z.string()
    })
  }, async c => {
    const body = await c.req.body()

    return `Hey, ${body.name}!` // < response body
  })

app.serve() // < launch app

❔ Please read our guide or join our Discord to learn more.





Release Schedule 🗓️

We strictly adhere to SemVer and post updates weekly.

  • current (e.g. v0.1.0)

    The current channel is dedicated to stable releases and is safe for use in production.

  • canary (e.g. v0.1.0-canary.0)

    The canary channel is meant for pre-releases that lack features for a stable release or contain features that are still a prototype. These releases are not suited for production and only meant for testing purposes.


Contributing 😘

We appreciate your help! 💕

To contribute, please read our contributing guidelines first.

cheetah1's People

Contributors

boywithkeyboard avatar github-actions[bot] avatar dependabot[bot] avatar mimimonads avatar jaymanmdev avatar

Stargazers

Violet avatar LPX avatar Brad Pillow avatar hharzer avatar  avatar Teerapat Prommarak avatar tiaxter avatar Florian Martin avatar  avatar Kassandra Streich avatar Jake Lees avatar Dmitry Petrov avatar hasundue avatar Rahim avatar Pocho avatar Mariusz Janczyn avatar  avatar Noah avatar Alexy_OS avatar Huynh Duc Duy avatar cheng avatar Chrs Msln avatar Mehdi Sadeghi avatar Sprint avatar  avatar 🍁 avatar Evgeni Atanasov avatar Eason avatar Success!!! avatar win avatar Emin Gasimov avatar Matthew Blode avatar Ruby avatar Chloe Arciniega avatar Jeton Kukalaj avatar Haitao Lee avatar Pasan Anuththara avatar Zhazha_JiaYiZhen avatar smiletosun avatar Bell avatar Aaronphy avatar  avatar 久绊A avatar 流浪大法师 avatar chencheng (云谦) avatar Anglo avatar Jivan Katwal avatar Tsiry Sandratraina avatar Willia.m avatar Andrew Ross avatar Lee Dogeon avatar yoko0180 avatar Okki Dwi avatar Harrison Malone avatar hsnmkls avatar Hong Minhee (洪 民憙) avatar Aidan Enseleit avatar Enzo Notario avatar Axhon avatar Nasim Uddin avatar CA Gustavo avatar Sarbeh avatar woqk avatar Ajay Jadhav avatar Max Marze avatar  avatar Alberto avatar Yuta Ueno avatar XavXander avatar Robin Goupil avatar İbrahim Ödev avatar Claudiu Andrei avatar Pranev (NeTT) avatar Eric David Smith avatar Ilya Medvedev avatar Andy Jiang avatar  avatar SK avatar Giorgio Bellisario avatar kyle avatar Richard avatar kit avatar dai avatar Urata Daiki avatar hashrock avatar Elias Sjögreen avatar Thomas Carvalho avatar Sean avatar Debarchito Nath avatar  avatar Matheus Santana avatar Guillaume Dumoulin avatar Vic avatar  avatar Amir Alam avatar Thomas Cruveilher avatar  avatar Donatas avatar David Luis avatar Leon Sorokin avatar

Watchers

Ly Nam avatar Dominic DiGiacomo avatar nora avatar

Forkers

mimimonads

cheetah1's Issues

Roadmap for v1.0

This issue is meant as both a roadmap and note regarding the upcoming v1.0 release.

Roadmap

  • reimagine the plugins api #77
  • implement documentation generation (part of v1.1)
  • introduce custom api client (will be a standalone module)
  • major performance enhancements
  • implement gzip compression using foras (not necessary for cloudflare workers or deno deploy) #79
  • support basic jsx rendering #96
  • standardize c.env across runtimes #85

Canceled

  • allow extending the fetch context

Breaking Changes

Helpers to register custom routes from extension

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

API versioning

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

Add support for tRPC

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

refactor: types for environment variables

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?

enhance dx for cloudflare

Enhance DX when building an API for Cloudflare Workers (install wrangler package behind the scenes, type-safe wrangler.toml, etc.).

option to validate request params

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.

Roadmap for v1.0

  • Built-in support for tRPC (#13)
  • Replace medleyjs/router with a custom router #29
  • Option to extend context
  • Parse headers without deep validation (refer to dae083f)
  • Improve the build script
    • Pre-compile pathname to regex
    • Remove if-else logic for plugins if none are used

include validation errors in the response body

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.

Setup script - folder name param

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

`ctx.req` isn't a standard `Request` object

I 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)
})

Roadmap for Official Plugins

cheetah v0.4.0 introduced support for plugins.

The following should be offered officially:

  • cache (Deno.KV, Redis, Cache API)
  • helmet (ported from here) #22
  • ratelimit (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.

Roadmap for v0.11.0

  • deprecate cache.duration option #46
  • enhance internal routing (delayed to v1.0 due to breaking changes)
  • add per-collection cache/cors options #50
  • implement automatic HEAD responses #49
  • add runtime option to build script #47
  • publish new guide (will be released separately this week)

c.exception() missing for extensions.

1.4.0

I'm getting a deprecated warning when using new Exception telling me to use c.exception() instead, but ExtensionContext doesn't have that function.

image

It's working well with normal routes, though.

image

Roadmap for v1.2

Roadmap

  • built-in high-performant server for static files (Cloudflare R2, S3 bucket or local files)
  • simple WebSockets implementation (experimental)
  • deprecate setup/build scripts & introduce an entire CLI with more commands
  • development mode (load env variables from a local .env file, make debugging easier, & add cheetah dev command)
  • improve DX when building an API for Cloudflare Workers (install wrangler package behind the scenes, type-safe wranger.toml, etc.)

When will v1.2 go public?

  • canary: Late July - Early August
  • current: Late August

Make `waitUntil` function suitable for Deno Deploy and self-hosting

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.

introduction of `c.res.cookies`

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.

Roadmap for v1.1

Roadmap

  • deprecate c.req.blob(), c.req.buffer(), c.req.formData() (extend body validation: z.instanceof(Blob) etc.) (delayed due to insufficient support by zod)
  • add etag extension (delayed to v1.2)
  • add favicon extension (respond to /favicon.ico requests) #126
  • add pretty extension (pretty-print json) #123
  • move transform option to c.req.body() method #118

+ other unscheduled revisions:

`req.text()` sets additional `Content-Type` header

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?

Screenshot:
image

add support for denoland/deno_kv_oauth

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

(non-issue) question about using jsdevlivr with esm.sh

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.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.