Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Site check

on:
pull_request:
push:
branches: [main]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: node --check server.js
- run: npm run check
36 changes: 36 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Makerble API docs

The site at api-docs.makerble.com. It is an Express app (`server.js`) deployed on Vercel.

- `openapi.yaml` (repo root): the OpenAPI spec, served at `/openapi.yaml` and used by the Prism mock server at `/mock`.
- `server.js`: the routes, plus the whole docs page (HTML, CSS and endpoint cards) in `buildDocsPage()`.
- `assets/`: the Makerble logo and favicon, served from `/assets/makerble-logo.png` and `/favicon.png`.
- `vercel.json`: must keep `includeFiles: ["assets/**", "openapi.yaml"]`. Without it, Vercel leaves those files out and the logo, favicon and spec return errors.

## Don't undo other people's changes

The Makerble branding (PR #52) was wiped out by a later docs commit. That commit was built from an out-of-date copy of `server.js`, so it rewrote the page styles and deleted `assets/` without anyone noticing. To stop that happening again:

- **Start from the latest `main`.** Fetch and merge `origin/main` before you edit, and again before you open a PR. Never paste or rewrite `server.js` wholesale from an older copy. Make targeted edits.
- **Check your diff before you commit.** A docs PR should only touch `openapi.yaml` and the endpoint cards or nav links in `server.js`. If `git diff --stat` shows changes to the `<style>` block, the `<head>`, `vercel.json`, `SPEC_PATH`, or deleted files under `assets/`, you are reverting someone's work. Stop and fix it.
- **Keep design changes in their own PR.** Branding, layout and server changes go in PRs of their own, separate from endpoint docs.
- **Run `npm run check` before pushing.** It boots the server and fails if the logo, favicon, Quicksand font, brand colours, or the `/openapi.yaml` route are missing. CI runs the same check on every PR.

## Branding

Match the Makerble app:

- Fonts: Quicksand for UI text, JetBrains Mono for code, paths and params.
- Colours: navy `#2d3e58` text, purple `#ac3898` primary accent (active nav, eyebrows, CTAs), blue `#2f6fb0` links.
- Layout: white header with the logo lockup, light sidebar, dark code panel on the right.
- Logo and favicon live only in `assets/`.

Use the CSS variables in `:root` rather than hard-coded colours. In nav links, use the `method-GET` / `method-POST` classes with no inline `style=`.

## Running locally

```
npm install
npm run dev # http://localhost:3000
npm run check # regression check
```
Binary file added assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/makerble-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"start": "node server.js",
"dev": "node --watch server.js"
"dev": "node --watch server.js",
"check": "node scripts/check-site.mjs"
},
"dependencies": {
"@stoplight/prism-cli": "^5.14.2",
Expand Down
82 changes: 82 additions & 0 deletions scripts/check-site.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* check-site.mjs — guards the docs site against accidental regressions.
*
* Boots server.js and checks that the routes and Makerble branding are intact.
* Run with `npm run check`; CI runs it on every pull request.
*/

import { spawn } from "child_process";
import { existsSync, readFileSync } from "fs";
import { fileURLToPath } from "url";
import { dirname, join } from "path";

const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const PORT = 3999;
const failures = [];
const fail = (msg) => failures.push(msg);

// ─── Static checks ───────────────────────────────────────────────────────────

for (const f of ["assets/makerble-logo.png", "assets/favicon.png", "openapi.yaml"]) {
if (!existsSync(join(root, f))) fail(`${f} is missing`);
}

const vercel = readFileSync(join(root, "vercel.json"), "utf8");
for (const f of ["assets/**", "openapi.yaml"]) {
if (!vercel.includes(f)) fail(`vercel.json no longer bundles "${f}" (includeFiles)`);
}

// ─── Runtime checks ──────────────────────────────────────────────────────────

const server = spawn(process.execPath, ["server.js"], {
cwd: root,
env: { ...process.env, PORT: String(PORT), PRISM_PORT: "4999" },
stdio: "ignore",
});

async function get(path) {
for (let i = 0; i < 30; i++) {
try { return await fetch(`http://localhost:${PORT}${path}`); }
catch { await new Promise((r) => setTimeout(r, 500)); }
}
throw new Error(`server never answered ${path}`);
}

try {
const page = await get("/");
const html = await page.text();
if (page.status !== 200) fail(`/ returned ${page.status}`);

const brand = {
"Makerble logo": "/assets/makerble-logo.png",
"favicon link": 'rel="icon"',
"Quicksand font": "family=Quicksand",
"navy text #2d3e58": "#2d3e58",
"purple accent #ac3898": "#ac3898",
};
for (const [name, marker] of Object.entries(brand)) {
if (!html.includes(marker)) fail(`docs page lost the ${name} (looked for "${marker}")`);
}

for (const [path, type] of [
["/openapi.yaml", "yaml"],
["/favicon.png", "png"],
["/favicon.ico", "png"],
["/assets/makerble-logo.png", "png"],
]) {
const res = await get(path);
const ct = res.headers.get("content-type") || "";
if (res.status !== 200 || !ct.includes(type)) fail(`${path} returned ${res.status} ${ct}`);
}
} catch (e) {
fail(e.message);
} finally {
server.kill();
}

if (failures.length) {
console.error("Site check failed:\n" + failures.map((f) => ` ✗ ${f}`).join("\n"));
console.error("\nSee CLAUDE.md — design and server changes must not ride along with docs PRs.");
process.exit(1);
}
console.log("Site check passed: routes, spec, logo, favicon and branding are intact.");
Loading
Loading