loopbackio / loopbackio/loopback-next
lb4 repository tool error if datasource is using injection
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
I have a simple data source, whos config is loaded via injection:
export class MainDataSource extends juggler.DataSource
implements LifeCycleObserver {
static dataSourceName = 'Main';
constructor(
@config()
dsConfig: object,
) {
super(dsConfig);
}
}
Application.ts:
this.configure('datasources.Main').to(options.datasources?.Main || {});
When running the repository scaffolding tool the following error occurs:
(node:24064) UnhandledPromiseRejectionWarning: Error: Cannot load C:\lb4\src\datasources\main.datasource.config.json: ENOENT: no such file or directory, open 'C:\lb4\src\datasources\main.datasource.config.json'
I am temporarily suppressing the error by adding a main.datasource.config.json file in the source directory.
However, this scaffolding tool should not require a fully configured data source to generate simple repositories. If the configuration cannot be found, it should just emit a warning, but still allow the tool to run and generate a non-customized class using the basic boilerplate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the injected datasource setup in Application.ts and reproduce the repository scaffolding command using the missing src/datasources/main.datasource.config.json path. Trace how the tool handles the missing configuration, then verify that it warns and still generates the basic repository class without requiring the file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100