Coder Social home page Coder Social logo

edgespec's People

Contributors

actions-user avatar codetheweb avatar ethanplee14 avatar mxsdev avatar seveibar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

zachbellay

edgespec's Issues

Allow middleware to declare parameters

Middleware should be allowed to declare parameters that get merged with route-level parameters.

For example, if there's an authentication middleware that relies on a property called access_token being present in the JSON body, it should be able to declare this directly on itself and receive the parsed value.

Alternatives:

  • await req.clone().json() (.clone() is necessary to avoid consuming the body). Simple but untyped, adds overhead, and dependent properties will not propagate to codegen.
  • parse request input, run user middleware, then run internal request validation middleware. Requires auth dependencies to be declared at the route level rather than the middleware level for types to propagate correctly.

No way to import `Middleware`

import type { EdgespecMiddleware } from "edgespec" or import { Middleware }

useful for typing something like this:

image

Type-safe middleware

Due to using the next based middleware model, we can't easily ensure type-safety on next(req), since the request we get will be of a different type than the one we return.

Outfit CI

Would be nice to have CI checks for build, typecheck, format, etc. Especially now that we have a lot of cooks in the kitchen.

A number of files seem to not have formatting applied for instance...

cc @razor-x

Add adapter for `http.IncomingMessage`

We need an adapter that allows you to host an EdgeSpec application on a Node server that's already running (the current Node adapter starts its own server).

Route type generation uses final parsed type of Zod schema rather than input type

If your route spec is:

withRouteSpec({
  queryParams: z.object({
    filter: z.string().transform(s => s.split(","))
  })
})

edgespec will write the type as

{
  queryParams: {
    filter: string[]
  }
}

instead of the correct

{
  queryParams: {
    filter: string
  }
}

Zod provides z.input<typeof schema> for this use case when using types. There's also a _input property available on schemas that seems to be the same thing as a value.

Allow `Request` to have `pathParams`

This is causing a type error in the node adapter right now

For now I'm probably gonna introduce WithEdgeSpecRequest<T> = T & { pathParams?: ... } or something like that, since that seems like the least controversial option for now

Disable Emulating WinterCG by default, however ask to enable it interactively in `edgespec init`

Emulating WinterCG is a way forcing endpoints to be maximally compliant with the standard, but just like with databases, people rarely build for multiple targets. We will suffer from the Lowest Common Denominator problem because every environment has additional features that users will want to access.

We should be the best standard for building APIs, and allow users to build for multiple targets and make usability a higher priority than compliance to maximize adoption and reduce initial onboarding struggles.

However, in edgespec init we should allow users to select this constraint.

As an anecdote, wintercg-minimal failed to build one of my projects, the build error was difficult to parse #35 so I gave up using edgespec. When I woke up this morning I felt a bit more confidence so I dug in and figured out it was the wintercg emulator and figured out it could be disabled, but our users won't have this same determination- this is mostly unrelated to the issue above since the emulator will eventually stabilize, but there is something to be said about being generous with emulation by default (lifting environments to the WinterCG standard without constraining them)

typecheck tests in ci

I think this is not happening right now, we might need to include it as part of tsc or something

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.