loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.95k stars 1.07k forks source link

From datasource config to DataSource instance with no custom classes #2557

Closed bajtos closed 3 years ago

bajtos commented 5 years ago

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.

// src/datasources/db.json
{
  "name": "db",
  "connector": "mysql",
  "url": "${ENV.MYSQL_URL}"
  "database": "dbname-used-at-dev-time"
}

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

Out of scope

bajtos commented 5 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/).

stale[bot] commented 4 years ago

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.

stale[bot] commented 3 years ago

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.