loopbackio / loopbackio/loopback-datasource-juggler
Strongly typed context types for operation hook typings
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 282
- Forks
- 366
- Avg merge
- 17h 4m
- Merged PRs (30d)
- 10
Description
@bajtos [suggested to provide strongly typed context types based on the hook name](https://github.com/strongloop/loopback-datasource-juggler/pull/1820#discussion_r383908186).
For example:
```ts
export interface AccessHookContext {
Model: T;
query: Filter;
}
export type Listener = (ctx: Ctx, next: (err?: any) => void) => void;
class PersistedModel {
// ...
static observe(operation: 'access', handler: Listener): void;
static observe(operation: 'before save', handler: Listener): void;
// etc.
}
```
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 discussion in pull request #1820 and the existing PersistedModel.observe operation-hook typings. Identify the context type needed for each hook named by the current API, then verify that each handler receives the corresponding context and that the TypeScript declarations remain consistent across operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100