mimiMonads / vixeny

💜 Vixeny: At the forefront of modern web development, runtime-independent, efficiency-driven library dedicated to upholding the principles of FP; Desgined for creating scalable, maintainable, and high-performance web applications.
https://vixeny.dev/
146 stars 6 forks source link

New API design #33

Closed aquapi closed 4 weeks ago

aquapi commented 1 month ago

Here's the new API design I'm thinking of that might looks more ergonomic. So instead of:

wrap({
  cyclePlugin: { hello }
})()
  .stdPetition({
    path: '/',
    method: 'GET',
    ...
  });

We can use:

vix()
  // Specify the plugin type as cycle in the plugin options
  .use(hello)
  .get('/', {
    ...
  });
mimiMonads commented 1 month ago

I know this is a way to make it more normal and I'm okay with it

.get('/', {
    f: () => 'hello world' 
  });

but the only issue is the return type, we have one mode where we return a Response and another one with a BodyInit, should we stick to returning a Response , do you like this new syntax @emastho

emastho commented 1 month ago

I know this is a way to make it more normal and I'm okay with it

.get('/', {
    f: () => 'hello world' 
  });

but the only issue is the return type, we have one mode where we return a Response and another one with a BodyInit, should we stick to returning a Response , do you like this new syntax @emastho

Well, this makes Vixeny more approachable to \<everyone>

The problem tho, it minimizes any uniqueness Vixeny had Under the hood its very unique, but to people its just "so this now just Elysia, but faster" Marketing is in shambles

mimiMonads commented 1 month ago

Maybe if we introduce get , post , put and delete and keep stdPetition ?

My idea of a serve implementation with the new syntax would be like:

await vix(opts)()
  .get({
    path: "/",
    f: () => new Response("hello world"),
  })
  .serve({
    port: 8080,
  });

Keeping all the current functionality, the problem I see with use is that we already set up everything in create

@emastho should I add .serve ?

mimiMonads commented 1 month ago

@aquapi also, I was thinking about adding addPetition instead of customPetition :

await vix(opts)()
  .addPetition({
    path: "/",
    f: () => new Response("hello world"),
  })
  .serve({
    port: 8080,
  });

and deprecate stdPetition , there's little use for it and it's confusing, keeping a Response as the object to return keeps consistency.

aquapi commented 1 month ago

I know this is a way to make it more normal and I'm okay with it

.get('/', {
    f: () => 'hello world' 
  });

but the only issue is the return type, we have one mode where we return a Response and another one with a BodyInit, should we stick to returning a Response , do you like this new syntax @emastho

Well, this makes Vixeny more approachable to

The problem tho, it minimizes any uniqueness Vixeny had Under the hood its very unique, but to people its just "so this now just Elysia, but faster" Marketing is in shambles

Not really though, every framework nowadays look like this. The major differences often are TypeScript support and request lifecycle

mimiMonads commented 1 month ago

Well we actually don't have a life cycle but a resolution , and it's end-to-end safe with TS support for deno, bun and focused on jsr.

There are things that are really difficult to change because this structure but also has a lot of advantage and it's specially easy to test and scale.