loopbackio / loopbackio/loopback-datasource-juggler

Strongly typed context types for operation hook typings

Open
#1,822 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

developer-experience feature good first issue
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.