Skip to main content
Explore how GitHub Copilot Chat can scaffold, debug, and document a Node.js REST API using slash commands and contextual understanding.

Scaffolding a Node.js REST API

Start by asking Copilot Chat to generate a minimal Express server with an in-memory users database (id, firstName, lastName, email). It instantly produces server.js:

Using /new to Scaffold Files

Instead of manually writing the code, use the /new slash command to bootstrap an entire project:
Copilot Chat generates an index.js with a standard Express setup:
You can tailor the /new command with additional options (e.g., include TypeScript or middleware) to fit your project needs.

Adding package.json and Splitting into app.js

To turn this into a maintainable Node.js application, Copilot Chat introduces a package.json and refactors the server:
Now index.js simply starts the server:
And app.js holds all request handlers:

Generating Tests

Copilot Chat can scaffold a comprehensive test suite with Jest and Supertest:

Installing and Running

  1. Install dependencies:
  2. Start the server:
    You’ll see:
  3. Test your API endpoints:

Working Set & Context

Copilot Chat leverages your working set—open files, recent edits, tests, and terminal output—to deliver contextual suggestions and reduce manual highlighting.

Key Slash Commands


Generating Documentation

Easily ask Copilot Chat to generate API docs without manual comments:

Switching AI Models

You can toggle between backends (e.g., ChatGPT-4, Claude) via the model dropdown in Copilot Chat to find the best fit for your workflow.

Watch Video