Hi:
It would a good idea create a new command bundle exec lotus add this command will create a new application inside apps folder, e.g:
bundle exec lotus generate app admin
and then it will create the needed files inside apps folder and it will add the needed code in the route of application, in lib or when it’s needed.
Thoughts?
Original topic: Lotus add new application for existing application · Issue #140 · hanami/hanami · GitHub
IMHO we should provide options to choose slice template. There are 2 types of slice that I could think of:
Default to Web slice and provide --slice_type
option to specify other type.
I agree. I think we should call it a slice generator tho. I think it’s pretty much there in the code already, it just needs to be hooked to the cli.
bundle exec lotus generate slice admin
bundle exec lotus generate slice api --type api
1 Like
When I was discussing with @AlfonsoUceda earlier, I mentioned my preference for calling it a ‘slice’, so .
now the generator to create new lotus app doesn’t support param type, should it be added this type param to this generator? because now the kind of slice is web type.
Thoughts?
I think we have 2 different things here. A new container application, that could have an api slice instead of a web one, and adding a slice to an existing container application. Am I right @AlfonsoUceda?
So new application, what about something like?
bundle exec lotus new chirp --slices admin:web api:api
=>
chirp/apps/admin
chirp/apps/api
Then a slice generator too
bundle exec lotus generate slice admin --type web
I don’t think there is a defined api slice type yet.
the question is, how will it be the api slice? does make sense support two type of slice?
a very good question and IMHO I do believe in supporting different type of slice.
As Web Service API has emerged to be a quite popular paradigm. In fact, it is one of the most popular application that companies are using Lotus atm (that includes me). And FYi there is a bit of works and it would not be easy enough for new adopters.
My suggestion is to start with bare metal template with bare minimum numbers of middlewares and default configurations. It is then up to us and users to customise their own slice template.
then we should work in this api convention to integrate in the new command an later work in the generate slice method.
E.g: support api versioning like grape.
Thoughts?
1 Like
@AlfonsoUceda when I have a chance, I’ll share the tweaked Lotus app for API Web Service.
Regarding versioning, it could be achieved with router, by mount it to different routes, for eg:
Lotus::Container.configure do
mount ApiV1::Application, at: '/api/v1'
mount ApiV2::Application, at: '/api/v2'
end
@trung_le ok perfect, we’ll let the routher the job
You can even do a cascading version, with Rack::Cascade
Are we planning to do controller/view type generators too?
Yes, we are going to have generator for views/controllers too.