Closed bajtos closed 3 years ago
Let's put this on hold for now, I would like to rethink the way how datasources are configured. I think the JSON-based config is not optimal for Cloud Native environments, where most configuration is handled by environmental variables (see https://12factor.net/).
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository. This issue will be closed within 30 days of being stale.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository.
In LoopBack 3, it is very easy to configure datasources with no code: just create a new entry in
server/datasources.json
and the bootstrapper + the runtime will automatically parse the configuration, replace placeholders like${MYSQL_URL}
with values from the environment variables and finally create & register a datasource instance.Let's implement similar functionality in LB4 too.
Note: having config for multiple datasources in a single JSON file can become a maintenance nightmare in larger applications, see strongloop/loopback#1316. It's better to have one config file per datasource, as we already do in TypeScript-based LB4 apps.
Acceptance criteria
[ ] JS & TS API for declarative registration of datasources.
We need to revisit
app.dataSource
API (IIRC, it's contributed by@loopback/repository
) and ensure that it supports declarative usage from both TypeScript and JavaScript.[ ] Support in
@loopback/boot
.Modify datasource booter to support the case where there is only datasource JSON file without any accompanying TS/JS file that would define a custom DataSource class.
[ ] Documentation
[ ] Blog post
Out of scope