gabrielcsapo / gabrielcsapo/node-git-server

Keeping context between calbacks

Open
#94 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
262
Forks
81
PR merge metrics
No merged PRs in 30d

Description

We have a `get-user-repo-access-info` procedure which is asynchronous - we run this in the `authenticate` callback as passed into the `Git` constructor. We do this to deny access to users before this library even looks for a git repo to use. However when we then get to the `push` event listener we're struggling to see how we can equate the original request with this specific callback. There is no shared state passed into the listener.

Would you be willing to help us rectify this? Honestly I'd be fine with just adding `http.IncomingMessage` to the `GitAuthenticateOptions` as `req` - I can then just add a property to that object :shrug:

It looks as though you've maybe kept the `authenticate` callback to accept the bare minimum of information though - if there's a specific reason for that perhaps we could add an empty `context` object to the `authenticate` callback which can then be passed to later event handlers. Avoiding giving the authenticate method any additional data to be mis-understood or used.

Thanks for the very helpful library, happy to open a PR for this, just wanted an idea of what is more likely to be merged.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the authenticate callback passed to the Git constructor and the later push event listener, focusing on GitAuthenticateOptions and the proposed context or req data. Define how request-specific state should travel between these callbacks, then verify that authentication and push handling can associate the same request without changing unrelated Git operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, nodejs, typescript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.