-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spike: booter for creating REST APIs from model files #3617
Conversation
// Start Application | ||
await app.start(); | ||
} | ||
|
||
async function givenTodoRepository() { | ||
todoRepo = await app.getRepository(TodoRepository); | ||
todoRepo = await app.get<TodoRepository>('repositories.TodoRepository'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a repository class we could use here, TodoRepository
is just a type alias for EntityCrudRepository<Todo, number>
.
import {GeocoderService} from '../../../services'; | ||
import {aLocation, givenTodo} from '../../helpers'; | ||
|
||
describe('TodoController', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see little value in writing unit tests for controllers contributed by 3rd-party packages. The controller code should have been already tested in that package (@loopback/rest-crud
in this case).
import {TodoRepository} from '../repositories'; | ||
import {GeocoderService} from '../services'; | ||
|
||
export class TodoController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No controller files, yay 🎉
import {DefaultCrudRepository, juggler} from '@loopback/repository'; | ||
import {Todo, TodoRelations} from '../models'; | ||
|
||
export class TodoRepository extends DefaultCrudRepository< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No repository files, yay 🎉
type: 'string', | ||
}) | ||
remindAtGeo?: string; // latitude,longitude | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to implement geocoder integration while using public-models/product.config.json
, we need to customize the controller method defined by @loopback/rest-crud
. That's kind of against the spirit of this change, where we want to use the default REST API as provided by LB. At least for the initial release, I'd like us to recommend users to switch from @loopback/rest-crud
to lb4 repository
& lb4 controller
if they need any tweaks in the built-in functionality.
12103a0
to
e116ab5
Compare
The spike is done and ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 Great effort. I left a few comments regarding the flexibility to modify the apis defined in controller class.
The todo example looks simple enough to config 👍
b7c6feb
to
67d1128
Compare
I have updated the spike as follows:
I consider this spike as done and ready for final review & approval. @strongloop/loopback-next PTAL. |
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
4f74b98
to
446d5f5
Compare
Signed-off-by: Miroslav Bajtoš <[email protected]>
Thank you all for feedback. I decided to address it the following way:
Let's do a final round of reviews and then call the spike done. |
Signed-off-by: Miroslav Bajtoš <[email protected]>
Since we are focused on REST for now If we support more flavors, they'll have their own names and reside in their own package, if not in a generic one where |
Oh, just realized your other point. I think it is important to give the context to Simply |
Exactly! I'll update the interface to |
It's ok if we don't get the names exactly right in the spike, we can tweak them later during code review of the real implementation. |
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Follow-up stories:
I am closing the spike as done. |
Quoting from #2036:
In this Spike, I am demonstrating a PoC implementation of an extensible booter
that processed model configuration files in JSON formats and uses 3rd-party
plugins to build repository & controller classes at runtime.
See SPIKE.md for further details.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈