amber icon indicating copy to clipboard operation
amber copied to clipboard

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

Open tekanic opened this issue 3 years ago • 1 comments
trafficstars

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

tekanic avatar Mar 05 '22 15:03 tekanic

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

crimson-knight avatar May 24 '22 20:05 crimson-knight

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

drujensen avatar Nov 18 '22 12:11 drujensen

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.

elorest avatar Nov 18 '22 21:11 elorest

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.

robacarp avatar Nov 18 '22 21:11 robacarp

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.

codered avatar Oct 25 '23 07:10 codered