You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dev/api-reference.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ head:
12
12
13
13
The central API exposes its functionality over HTTP from `ui/server/api`. This page is a reference to those endpoints.
14
14
15
-
> [!WARNING] > **Internal and evolving.** These endpoints currently power Codefair's own web UI and are authenticated with the browser **session cookie**, not API tokens. They are documented here as the foundation of the planned **public REST API** — paths, payloads, and the auth model may change before a stable, token-authenticated, versioned API is released. Treat this as a contributor reference, not a public contract.
15
+
> [!WARNING] > **Internal and evolving.** These endpoints currently power Codefair's own web UI and are authenticated with the browser **session cookie**, not API tokens. They are documented here as the foundation of the planned **public REST API**, so paths, payloads, and the auth model may change before a stable, token-authenticated, versioned API is released. Treat this as a contributor reference, not a public contract.
16
16
17
17
## :gear: Conventions
18
18
@@ -54,7 +54,7 @@ Each FAIR check exposes a consistent trio: `GET` current state, `POST` to create
54
54
55
55
> [!NOTE]
56
56
> A second, older pair of routes exists at `/dashboard/[owner]` and
57
-
> `/dashboard/[owner]/[repo]`. No page calls them — the UI uses
57
+
> `/dashboard/[owner]/[repo]`. No page calls them; the UI uses
58
58
> `/[owner]/dashboard` and `/[owner]/[repo]/dashboard` above. Treat them as
59
59
> deprecated and don't build on them.
60
60
@@ -118,7 +118,7 @@ the browser rather than by `fetch`.
|`server/plugins/`| Nitro startup plugins, e.g. `env-check.ts` which fails fast on missing env vars. |
77
77
78
78
The `services/` folder is where most feature work happens:
79
79
80
-
-**`services/webhooks/`** — one handler per GitHub event family: `installation.ts`, `push.ts`, `pull-request.ts`, `issues.ts`.
81
-
-**`services/compliance/`** — the FAIR checks: `license.ts`, `metadata.ts`, `readme.ts`, `contributing.ts`, `cwl.ts`, orchestrated by `index.ts`.
82
-
-**`services/providers/`** — the platform abstraction: `interface.ts` (the contract) and `github.ts` (the GitHub implementation).
83
-
-**`services/github-app/`** —`client.ts` wires up the Octokit `App` and hands out installation-scoped clients.
84
-
-**`services/dashboard/`** —`manager.ts` (reads/writes the dashboard issue) and `renderer.ts` (pure markdown builder).
85
-
-**`services/archival/`** —`interface.ts` (the `ArchivalProvider` contract) and `zenodo.ts` (the Zenodo implementation).
80
+
-**`services/webhooks/`**: one handler per GitHub event family: `installation.ts`, `push.ts`, `pull-request.ts`, `issues.ts`.
81
+
-**`services/compliance/`**: the FAIR checks: `license.ts`, `metadata.ts`, `readme.ts`, `contributing.ts`, `cwl.ts`, orchestrated by `index.ts`.
82
+
-**`services/providers/`**: the platform abstraction: `interface.ts` (the contract) and `github.ts` (the GitHub implementation).
83
+
-**`services/github-app/`**:`client.ts` wires up the Octokit `App` and hands out installation-scoped clients.
84
+
-**`services/dashboard/`**:`manager.ts` (reads/writes the dashboard issue) and `renderer.ts` (pure markdown builder).
85
+
-**`services/archival/`**:`interface.ts` (the `ArchivalProvider` contract) and `zenodo.ts` (the Zenodo implementation).
86
86
87
87
## :inbox_tray: How a webhook is handled
88
88
@@ -116,16 +116,16 @@ sequenceDiagram
116
116
117
117
Key handlers:
118
118
119
-
-**`installation` / `installation_repositories`** — a repo was added or removed. On add, Codefair creates an `Installation` row, runs the first compliance check, and opens the dashboard issue. (To protect against bulk installs, only the first repositories get a full run; the rest are rate-limited.)
120
-
-**`push`** — only the default branch is processed. Codefair re-runs the checks and updates the dashboard.
121
-
-**`pull_request`** — tracks the Codefair-created PRs (license, README, …) so the dashboard can show their status.
-**`installation` / `installation_repositories`**: a repo was added or removed. On add, Codefair creates an `Installation` row, runs the first compliance check, and opens the dashboard issue. (To protect against bulk installs, only the first repositories get a full run; the rest are rate-limited.)
120
+
-**`push`**: only the default branch is processed. Codefair re-runs the checks and updates the dashboard.
121
+
-**`pull_request`**: tracks the Codefair-created PRs (license, README, …) so the dashboard can show their status.
122
+
-**`issues`**: reopening the dashboard issue restores it; closing updates state.
123
123
124
124
## :electric_plug: The provider abstraction (multi-platform support)
125
125
126
126
The most important design decision is that **compliance services never touch
127
127
Octokit directly**. Instead they receive a `RepositoryProvider`
128
-
(`server/services/providers/interface.ts`) — a platform-agnostic contract with
128
+
(`server/services/providers/interface.ts`), a platform-agnostic contract with
129
129
methods like `getFileContent`, `listDirectory`, `commitFile`,
130
130
`createPullRequest`, and `createIssue`.
131
131
@@ -144,8 +144,8 @@ flowchart TD
144
144
`GitHubRepositoryProvider` (`providers/github.ts`) implements that contract
145
145
today by translating each method into an Octokit request. A future
146
146
`GitLabRepositoryProvider` will implement the **same** interface, and the
147
-
compliance code will not need to change. This is what makes GitLab support — and
148
-
the eventual public REST API — tractable. See
147
+
compliance code will not need to change. This is what makes GitLab support (and
148
+
the eventual public REST API) tractable. See
149
149
[Platform Providers (GitLab)](./providers.md) for how to add one.
150
150
151
151
Archival follows the same pattern: `ArchivalProvider`
Copy file name to clipboardExpand all lines: docs/dev/compliance-check.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ head:
10
10
11
11
# Adding a Compliance Check :sparkles:
12
12
13
-
A **compliance check** is a single FAIR rule Codefair evaluates for a repository — for example "does a `LICENSE` file exist?" or "is the `codemeta.json` valid?". Each check produces a result that is stored in the database and rendered as a section of the repository's **FAIR Compliance Dashboard** issue.
13
+
A **compliance check** is a single FAIR rule Codefair evaluates for a repository. For example, "does a `LICENSE` file exist?" or "is the `codemeta.json` valid?". Each check produces a result that is stored in the database and rendered as a section of the repository's **FAIR Compliance Dashboard** issue.
14
14
15
15
Codefair is deliberately modular: checks are small functions that receive a platform-agnostic [`RepositoryProvider`](./providers.md) and are wired into a single orchestrator, `runComplianceChecks()`. This page walks through adding a brand-new check end-to-end by building an example that verifies an `expecto_patronum.md` file exists.
16
16
@@ -68,7 +68,7 @@ export async function checkForExpecto(
68
68
```
69
69
70
70
> [!IMPORTANT]
71
-
> Always go through the `provider` (`getFileContent`, `listDirectory`, `commitFile`, …) — **never** import Octokit directly in a compliance service. This is what lets the same check run unchanged on GitHub today and GitLab in the future. See [Platform Providers](./providers.md).
71
+
> Always go through the `provider` (`getFileContent`, `listDirectory`, `commitFile`, …). **Never** import Octokit directly in a compliance service. This is what lets the same check run unchanged on GitHub today and GitLab in the future. See [Platform Providers](./providers.md).
72
72
73
73
## **Step 3**: Register the check in the orchestrator
@@ -154,7 +154,7 @@ To write results back, follow the pattern in `server/services/compliance/license
154
154
155
155
## **Step 5**: Render it on the dashboard
156
156
157
-
The dashboard issue body is built by `server/services/dashboard/renderer.ts` — a pure functionthat turns the compliance results into Markdown. Add a section renderer modelled on `renderReadme()`:
157
+
The dashboard issue body is built by `server/services/dashboard/renderer.ts`, a pure functionthat turns the compliance results into Markdown. Add a section renderer modelled on `renderReadme()`:
158
158
159
159
```typescript
160
160
functionrenderExpecto(
@@ -191,14 +191,14 @@ Then call it from `renderDashboard()` and add the data to the `DashboardSections
191
191
body += renderExpecto(owner, repo, expecto);
192
192
```
193
193
194
-
When `renderDashboard()` runs, the dashboard manager (`server/services/dashboard/manager.ts`) updates the single GitHub issue for the repository — no extra wiring needed.
194
+
When `renderDashboard()` runs, the dashboard manager (`server/services/dashboard/manager.ts`) updates the single GitHub issue for the repository, with no extra wiring needed.
195
195
196
196
## **Step 6**: Test the feature
197
197
198
198
Run the stack locally (see [Running Locally](./running-locally.md)):
199
199
200
200
```bash
201
-
# In ui/ — runs the Nuxt server plus the Smee webhook proxy
201
+
# In ui/: runs the Nuxt server plus the Smee webhook proxy
0 commit comments