amberframework / amber

A Crystal web framework that makes building applications fast, simple, and enjoyable. Get started with quick prototyping, less bugs, and blazing fast performance.
https://amberframework.org
MIT License
2.57k stars 205 forks source link

[CLI][Feature Request] Amber new --api #1273

Closed tekanic closed 9 months ago

tekanic commented 2 years ago

[Feature Request]

It would be great if the project generator automatically created the necessary pipes and endpoints with jwt configured if you specify --api when creating a new project.

crimson-knight commented 2 years ago

@tekanic this sounds like a great idea! Is this something you think you would be able to contribute towards?

drujensen commented 1 year ago

The existing amber generate api Post title:string body:text will create a different pipeline:

  pipeline :api do
    plug Amber::Pipe::Error.new
    plug Amber::Pipe::Logger.new
    plug Amber::Pipe::Session.new
    plug Amber::Pipe::CORS.new
  end

You can add a new Pipe that decodes the token with this JWT library: https://github.com/crystal-community/jwt

elorest commented 1 year ago

What @drujensen said. In addition it's currently setup to send an encrypted json block back with set-cookie header. I don't think we really gain anything by switching to JWT that isn't already happening, unless you intend for the client to be able to modify the token.

robacarp commented 1 year ago

I agree that there is no reason to assume that someone would want JWT by default. HTTP session and cookie are more than enough for a default, and they create far less headache on the front-end, too.

codered commented 9 months ago

A solution has been provided and no updates on this feature for almost a year. It is safe to close and if we really need JWT a new feature request can be open.