Tutorial: Node.js Express API
What This Tutorial Will Cover
Section titled “What This Tutorial Will Cover”When Node.js support lands, this tutorial will walk through:
- Creating a minimal Express HTTP API with two routes (
GET /healthandGET /greet) - Writing Jest tests with
--coverageto generate acoverage/coverage-summary.jsonreport - Running
nolapse init --repo . --lang nodejsto create the baseline - Simulating a coverage regression by removing a test
- Running
nolapse run --repo . --lang nodejsand seeing it exit 1 - Adding a GitHub Actions workflow that gates PRs on coverage
Expected Project Structure
Section titled “Expected Project Structure”hello-express/├── src/│ ├── handler.js│ └── handler.test.js├── package.json├── jest.config.js├── .audit/│ └── coverage/│ └── baseline.md└── nolapse.yamlExpected Commands (Once Available)
Section titled “Expected Commands (Once Available)”Initialise
Section titled “Initialise”nolapse init --repo . --lang nodejsRun a check
Section titled “Run a check”nolapse run --repo . --lang nodejsGitHub Actions workflow
Section titled “GitHub Actions workflow”name: Coverage check
on: pull_request:
jobs: coverage: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0
- name: Set up Node uses: actions/setup-node@v4 with: node-version: "20"
- name: Install dependencies run: npm ci
- name: Run nolapse uses: nolapse/nolapse-action@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} lang: nodejs warn-threshold: "0.5" fail-threshold: "1.0"Coverage Report Format
Section titled “Coverage Report Format”nolapse will read Jest’s coverage/coverage-summary.json format. To generate it, Jest must be configured with:
{ "coverageReporters": ["json-summary"]}Or in jest.config.js:
module.exports = { coverageReporters: ["json-summary", "text"],};Get Notified
Section titled “Get Notified”Watch the nolapse changelog for the Node.js runner release. Once available, this tutorial will be updated with full working commands and example output.
See Also
Section titled “See Also”- Multi-Language Projects — run Go and Python components alongside Node.js once it ships
- Tutorial: Go Microservice — a fully working tutorial available today
- Tutorial: Python Django App — a fully working tutorial available today