This repository was archived by the owner on Jun 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
docs: refactor and expand docs #47
Open
polyipseity
wants to merge
27
commits into
main
Choose a base branch
from
add-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0fbe36a
feat: API monitoring (#49)
wylited 061ee0f
docs: update readme to be more concise
polyipseity 81f14dc
docs: add quickstart and development setup
polyipseity d28785d
docs: migrate and add plugins and routes docs
polyipseity 7b75761
docs: deduplicate docs
polyipseity 570747a
docs: add testing, linting, and CI
polyipseity 090592a
docs: add Docker and deployment
polyipseity 9f07674
docs: fix typo
polyipseity fe2bb2f
docs: improve `.env.example` and add env var docs
polyipseity 957ef00
docs: document `.env` ignore policy in `env-vars.md`
polyipseity 44b6089
docs: format `CONTRIBUTING.md`
polyipseity da6a5d2
docs: edit `CONTRIBUTING.md` for wording
polyipseity 639d2dd
docs: add release automation docs
polyipseity 406c403
docs(ci): document reusable workflows and hosted-first self-hosted fa…
polyipseity 75901c1
docs(ci): update workflow docs for shared-step try→fallback pattern a…
polyipseity 3248d4f
docs(ci): update workflow docs - detect-quota, hosted-first fallback,…
polyipseity a74e871
docs(ci): add TypeDoc generation and publishing; update README, .giti…
polyipseity 6bab141
docs(ci): add docs-publish workflow; generate & publish TypeDoc; upda…
polyipseity 4c06e8e
ci(workflows): enable Corepack, use numeric node-version and add Node…
polyipseity d75f0e6
docs: add script docs (compile, lint:check, fmt) and fix lint command
polyipseity 528e9b5
ci: update docs publish workflow
polyipseity 2104cad
docs: fix docs links
polyipseity de44672
ci: fix
polyipseity dcbde4a
docs: sync documentation with code — clarify test runner and .env han…
polyipseity 8051c2a
chore: format
polyipseity da95b48
ci: bump action versions
polyipseity d34eab4
docs: fix readme
polyipseity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,21 @@ | ||
| # Description: Example of .env file | ||
| # Example .env file for local development and tests | ||
|
|
||
| # MongoDB URI | ||
| # MongoDB (required) | ||
| MONGO_URI=mongodb://localhost:27017/example | ||
|
|
||
| # Auth Plugin | ||
| # OpenID Connect (used by the auth plugin) | ||
| # AUTH_DISCOVERY_URL should point to the provider's discovery document (/.well-known/openid-configuration) | ||
| AUTH_DISCOVERY_URL=https://login.microsoftonline.com/c917f3e2-9322-4926-9bb3-daca730413ca/v2.0/.well-known/openid-configuration | ||
| AUTH_CLIENT_ID=b4bc4b9a-7162-44c5-bb50-fe935dce1f5a | ||
|
|
||
| # When true, the auth plugin skips remote discovery and verification (useful for local testing) | ||
| AUTH_SKIP=true | ||
|
|
||
| # Optional runtime controls | ||
| NODE_ENV=development | ||
| PORT=3000 | ||
|
|
||
| # Test helpers (optional) | ||
| # Provide these only when running integration tests that require a real token/user. | ||
| TEST_AUTH_TOKEN= | ||
| TEST_AUTH_USER= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| name: docs:publish | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| detect-quota: | ||
| # Probe the hosted runner so we can decide whether to use hosted or self-hosted. | ||
| runs-on: ubuntu-slim | ||
| steps: | ||
| - name: Quota probe | ||
| id: quota_probe | ||
| run: | | ||
| echo "probe" | ||
|
|
||
| build-and-publish: | ||
| needs: detect-quota | ||
| # NOTE: do not set `continue-on-error` on detect-quota (see docs) | ||
| runs-on: ${{ needs.detect-quota.result == 'success' && 'ubuntu-slim' || 'self-hosted' }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Use Node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Enable Corepack | ||
| run: | | ||
| corepack enable | ||
| corepack install | ||
|
|
||
| - name: Enable Node cache | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| cache: yarn | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| yarn install --immutable | ||
|
|
||
| - name: Build project | ||
| run: | | ||
| yarn build | ||
|
|
||
| - name: Generate TypeDoc | ||
| run: | | ||
| yarn docs:typedoc | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: api-docs | ||
| path: docs/api | ||
|
|
||
| - name: Publish to GitHub Pages | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: ./docs/api | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: docs | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
|
Comment on lines
+1
to
+7
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| detect-quota: | ||
| # Probe the hosted runner so we can decide whether to use a hosted | ||
| # runner or fall back to self-hosted. The job should fail if quota is exhausted. | ||
| runs-on: ubuntu-slim | ||
| steps: | ||
| - name: Quota probe | ||
| id: quota_probe | ||
| run: | | ||
| echo "probe" | ||
|
|
||
| build: | ||
| needs: detect-quota | ||
| # NOTE: Do not set `continue-on-error: true` on the `detect-quota` job. | ||
| # If `continue-on-error` is enabled the job result will always be | ||
| # 'success', which defeats detection (we rely on `needs.detect-quota.result`). | ||
| runs-on: ${{ needs.detect-quota.result == 'success' && 'ubuntu-slim' || 'self-hosted' }} | ||
| steps: | ||
|
polyipseity marked this conversation as resolved.
|
||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Use Node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Enable Corepack | ||
| run: | | ||
| corepack enable | ||
| corepack install | ||
|
|
||
| - name: Enable Node cache | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| cache: yarn | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| yarn install --immutable | ||
|
|
||
| - name: Build project | ||
| run: | | ||
| yarn build | ||
|
|
||
| - name: Generate TypeDoc | ||
| run: | | ||
| yarn docs:typedoc | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: api-docs | ||
| path: docs/api | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +1,70 @@ | ||
| # USThing Template API | ||
| # template-api | ||
|
|
||
| The template repository for USThing backend services, powered by Fastify. | ||
| <!-- NOTE: If you use this repository as a template, replace `USThing/template-api` with your own GitHub owner/repo in the badge URLs. --> | ||
|
|
||
| ## Available Scripts | ||
| [](https://github.com/USThing/template-api/actions/workflows/check.yml) [](https://github.com/USThing/template-api/actions/workflows/docs-publish.yml) [](https://github.com/USThing/template-api/actions/workflows/release.yml) [](https://usthing.github.io/template-api/index.html) | ||
|
|
||
| In the project directory, you can run: | ||
| A concise Fastify + TypeScript starter used by USThing backend services. This repository provides a minimal, well-tested scaffold with recommended scripts, linting, and CI configuration. | ||
|
|
||
| ### `yarn run dev` | ||
| ## Prerequisites | ||
|
|
||
| Run the app in development mode; watch the source for changes. | ||
| - Node.js (see `engines` in `package.json`) | ||
| - Yarn via Corepack | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
| Enable Corepack (recommended) and the Yarn version used by this repo: | ||
|
|
||
| ### `yarn run compile` | ||
| ```bash | ||
| corepack enable | ||
| # `packageManager` field in `package.json` ensures the correct Yarn version is used | ||
| ``` | ||
|
|
||
| Run the TypeScript compiler to check for type errors. | ||
| ## Quickstart (local) | ||
|
|
||
| ### `yarn run build`, `yarn run start` | ||
| ```bash | ||
| corepack enable | ||
| yarn install | ||
| yarn build | ||
| yarn start | ||
| ``` | ||
|
|
||
| - Build the app for production to the `dist` folder. | ||
| - Start the built app in production mode. | ||
| ## Developer workflow | ||
|
|
||
| ### `yarn run test` | ||
| - Start dev mode (watch + Fastify): `yarn dev` | ||
| - Run tests (TypeScript tests run via `tsx`): `yarn test` | ||
| - Lint and format (auto-fixes): `yarn lint` and `yarn fmt` | ||
|
|
||
| Run the tests. | ||
| ## Automatic API docs | ||
|
|
||
| ### `yarn run lint` | ||
| API docs are generated from source by TypeDoc and published by CI. To generate locally: | ||
|
|
||
| Run the linter and fix any issues. | ||
| ```bash | ||
| yarn docs:typedoc | ||
| ``` | ||
|
|
||
| `lint:check` does not fix the issues. | ||
| Generated docs are placed under `docs/api` (CI publishes these artifacts — do not commit generated files). | ||
|
|
||
| ### `yarn run fmt` | ||
| ## Project layout | ||
|
|
||
| Run the formatter and fix any issues. | ||
| - `src/` — application code (routes, plugins, utils) | ||
| - `src/app.ts` — Fastify app and plugin registration | ||
| - `src/routes/` — route modules | ||
| - `test/` — tests and helpers | ||
| - `docs/` — human-authored guides and docs | ||
| - `.env.example` — example environment variables | ||
|
|
||
| `fmt:check` does not fix the issues. | ||
| ## Environment | ||
|
|
||
| ## Environment Variables | ||
| Tests and some dev helpers reference `TEST_AUTH_TOKEN` / `TEST_AUTH_USER`. See `docs/env-vars.md` for recommended env variables and CI secret usage. Keep secrets out of the repo and use your CI's secret manager. | ||
|
|
||
| For Fastify-level environment variables, please refer to the [fastify-cli documentation](https://github.com/fastify/fastify-cli). | ||
| ## Contributing | ||
|
|
||
| For the application-level environment variables, please refer to the | ||
| `.env.example` file. `yarn run dev` automatically loads a `.env` file if it exists. | ||
| Follow `CONTRIBUTING.md` (commitlint, lint, tests). The project uses Conventional Commits for releases. | ||
|
|
||
| ## CI / CD | ||
| ## Support | ||
|
|
||
| This template supports GitHub Actions for CI / CD. The available workflows are: | ||
| Open an issue on GitHub using the provided templates for bugs or feature requests. | ||
|
|
||
| - Checks / eslint: Run ES Lint to check problems and the format of the code. | ||
| - Checks / commitlint: Run Commitlint to check the format of the commit messages. | ||
| - Checks / tests: Run unit tests of the project. | ||
| - Docker CI / docker: Build the Docker image and push it to the GitHub Container Registry. | ||
| - Release Please / release-please: Automatic releasing. See also [release-please](https://github.com/googleapis/release-please). | ||
| ## Learn more | ||
|
|
||
| ## Learn More | ||
|
|
||
| To learn Fastify, check out the [Fastify documentation](https://fastify.dev/docs/latest/). | ||
| - Fastify: <https://www.fastify.dev/> | ||
| - Docs folder: `docs/` (detailed guides and examples) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||
| # CI workflows | ||||||
|
|
||||||
| The repository uses three primary GitHub Actions workflows in `.github/workflows/`: | ||||||
|
|
||||||
| - `check.yml` — runs on push and pull_request. It probes runner availability (a small `detect-quota` job) and then runs ESLint, commitlint, and tests. Each job uses a hosted-first → self-hosted fallback by selecting `runs-on` based on the probe result. | ||||||
| - `docker.yml` — builds and pushes container images (Buildx). It also probes runner availability and uses a hosted-first fallback. The workflow prepares Docker metadata (tags include sha, branch/ref, and PR tags) and pushes images to `REGISTRY`/`IMAGE_NAME`. | ||||||
| - `release.yml` — runs `googleapis/release-please-action@v4` on pushes to `main`. When a release is created the workflow tags versions and (optionally) builds/pushes images. See `release.yml` for the exact tagging and build steps. | ||||||
|
|
||||||
| ## Key notes | ||||||
|
|
||||||
| - Hosted-first fallback: jobs use a small probe job (`detect-quota`) and set `runs-on` dynamically so CI prefers `ubuntu-latest` but can fall back to `self-hosted` when needed. | ||||||
|
||||||
| - Hosted-first fallback: jobs use a small probe job (`detect-quota`) and set `runs-on` dynamically so CI prefers `ubuntu-latest` but can fall back to `self-hosted` when needed. | |
| - Hosted-first fallback: jobs use a small probe job (`detect-quota`) and set `runs-on` dynamically so CI prefers `ubuntu-slim` but can fall back to `self-hosted` when needed. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.