finos / finos/git-proxy

Extensibility through Event Hooks

Open
#1,449 14 comments 2 reactions 1 assignee Claimed by @Andreybest View on GitHub
enhancement
Dominant language
TypeScript
Stars
249
Forks
176
Avg merge
3d 8h
Merged PRs (30d)
20

Description

# Summary

Organizational deployments of Git Proxy often need to run organization-specific integrations before and after Git Proxy actions are performed, such as clone, pull, and push.

Examples include:

- integration with internal request or approval systems
- fine-grained entitlement system integrations
- chat or notification integrations
- organization-specific scanners or processing hooks

## Proposal

Introduce a simple, lightweight, and well-abstracted event system that external integrations can hook into.

These interfaces should be abstracted from Git Proxy internals and should expose only the logical operations Git Proxy is performing. This would allow organizations to extend behavior without coupling directly to internal workflow or chain implementation details.

## Example

A simple example of an email handler:

```ts
proxy
.registerEventHandler()
.onPull()
.onCompleted(myEmailHandler);

async function myEmailHandler(repo: RepositoryContext, user: UserContext): Promise {
// Check whether this is the user's first pull of the repository
if (await isFirstPull(repo, user)) {
const emailBody = `
Welcome to Git Proxy.

Here is everything you need to get started before submitting your first push request...
`;

await email.send(user.emailAddress, "Getting started with Git Proxy", emailBody);
}
}
```

## Proposed API

```ts
interface IProxyEventRegistry {
onPull(): IActionEventHandler;
onClone(): IActionEventHandler;
onPush(): IActionEventHandler;
}
```

```ts
interface IActionEventHandler {
onStarted(handler: ActionEventCallback): IActionEventHandler;
onCompleted(handler: ActionEventCallback): IActionEventHandler;
onError(handler: ActionErrorEventCallback): IActionEventHandler;
onPermissionDenied(handler: ActionEventCallback): IActionEventHandler;
}
```

```ts
type ActionEventCallback = (
repo: RepositoryContext,
user: UserContext
) => void | Promise;

type ActionErrorEventCallback = (
repo: RepositoryContext,
user: UserContext,
error: Error
) => void | Promise;
```

## Notes

While the existing chain could theoretically be modified to insert additional actions, that approach is cumbersome and invasive because it requires integrations to hook directly into the core execution flow of Git Proxy.

That would make future workflow refactoring significantly harder, since external users would then become dependent on internal chain handler interfaces and execution semantics.

A dedicated event model would provide a cleaner extension point, with lower coupling and a clearer contract for organizational integrations.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.