loopbackio / loopbackio/loopback-next

Clean up datasource template

Abierto
#5,220 9 comentarios 0 reacciones 1 asignado Ver en GitHub

@mrmodise ya está trabajando en esto.

Desde el 21/2/2021.

good first issue Hacktoberfest tech-debt
Lenguaje dominante
TypeScript
Estrellas
5.1k
Forks
1.1k
Merge medio
2 d 21 h
PR fusionados (30 d)
27

Descripción

This is a follow-up issue for #5000 where we moved datasource config from JSON files to TS files and discovered few aspects of the datasource template that can be improved.

- [x] Update https://github.com/strongloop/loopback4-example-shopping to follow the new style
- [ ] Update https://github.com/strongloop/loopback-next/blob/master/docs/site/Inside-Loopback-Application.md to follow the new style
- [ ] Make the static DataSource property `name` read-only, set it from `config.name` to avoid duplication.
- [ ] Rework datasources to receive the configuration via `@config`, so that they can be configured via `app.configure()`. Update the docs (especially Cloudant & Bluemix guides), make sure to preserve content for the old configuration style (think of existing projects created before the change).
- [ ] Fix datasource files in `examples` to use the same style as scaffolded by `lb4 datasource`. Most notably, change them to participate in app life-cycle and disconnect when the application has stopped. Update the docs accordingly.
- [ ] Verify that integration tests instantiating datasource classes directly are stopping them after the tests are over + update the relevant docs (e.g. testing best practices).
- [x] Remove start/stop code in favor of `stop()` method provided directly by juggler, see https://github.com/strongloop/loopback-datasource-juggler/pull/1835 and #5279

## Acceptance criteria

For each of the items above, consider the following places to update
- The template in [packages/cli/generators/datasource/templates/datasource.ts.ejs](https://github.com/strongloop/loopback-next/blob/master/packages/cli/generators/datasource/templates/datasource.ts.ejs)
- The template used by CLI tests - see [getSourceForDataSourceClassWithConfig()](https://github.com/strongloop/loopback-next/blob/89fc25fbc9ef3523a9306abcb39ce2054f7d2da7/packages/cli/test/test-utils.js#L145-L164)
- All documentation pages in [`docs/site`](https://github.com/strongloop/loopback-next/tree/master/docs/site), do a text search to find all snippets showing a datasource
- All example applications in [`examples`](https://github.com/strongloop/loopback-next/tree/master/examples)

---

## 🎆 Hacktoberfest 2020

Greetings :wave: to all Hacktoberfest 2020 participants!

Here are few tips 👀 to make your start easier, see also #6456:

- Before you start working on this issue, please leave a comment to let others know.
- This issue consists of several tasks to work on, it may feel like a too big effort to undertake. Don't worry! It's perfectly fine to pick just one item from the list and leave the rest for somebody else. In fact, we prefer to have a dedicated pull request for each part, to make it easier for us to review the changes and get the pull request landed faster. Baby steps FTW! Remember, every little helps.
- If you are new to GitHub pull requests, then you can learn about the process in [Submitting a pull request to LoopBack 4](https://loopback.io/doc/en/lb4/submitting_a_pr.html).
- If this is your first contribution to LoopBack, then please take a look at our [Developer guide](https://loopback.io/doc/en/lb4/code-contrib-lb4.html)
- Feel free to ask for help in `#loopback-contributors` channel, you can join our Slack workspace [here](https://join.slack.com/t/loopbackio/shared_invite/zt-8lbow73r-SKAKz61Vdao~_rGf91pcsw).

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.