P
💻DeveloppementBeginnerChatGPT

Create Your First API with Express.js

Learn to create your first Express.js REST API from A to Z with pedagogical explanations adapted to beginners.

Paste in your AI

Adapt this prompt

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

You are a friendly, supportive web development instructor who specializes in teaching Node.js to beginners. I'm new to backend development and I want to create my first API with Express.js.

My current level:

  • JavaScript knowledge: [e.g. basics (variables, functions, loops), intermediate (async/await, destructuring)]
  • Backend experience: [e.g. none, or I've written a few Node.js scripts]
  • IDE I use: [e.g. VS Code]

What I want to build:
[e.g. a task management API (todo list), a blog API, an API for managing contacts]

Guide me step by step through building this API, explaining each concept in simple terms:

  1. Project setup: npm initialization, installing Express and the essential dependencies (nodemon, dotenv), folder structure.
  2. First Express concepts: explain req, res, next with simple analogies. Create the first GET and POST routes.
  3. Full CRUD: implement the 4 operations (Create, Read, Update, Delete) with the appropriate HTTP methods.
  4. Simple database: start with an in-memory array, then migrate to a SQLite or JSON database with explanations.
  5. Basic validation: validate user input before processing it.
  6. Testing with Thunder Client or Postman: provide the test requests for each endpoint.
  7. Common mistakes: list the 5 most frequent beginner mistakes and how to avoid them.

Use plenty of comments in the code and explanations in plain, accessible language.

Personalize this prompt with Léa · AI assistant

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

This prompt is calibrated for beginners thanks to several key elements: the request for explanations with simple analogies, using in-memory storage first before a real database (reducing initial complexity), and the preventive list of common errors. The complexity progression (in-memory array, SQLite, PostgreSQL if desired) is a proven pedagogical approach: exposing a beginner directly to a PostgreSQL database with connection pooling and migrations would be overwhelming. This gradation allows mastering each concept before introducing a new one. Requesting ready-to-use Postman/Thunder Client requests is a practical bonus that allows the beginner to test their API immediately without having to learn another tool from scratch at the same time.

Use Cases

Learning backend developmentNode.js and Express trainingCreating first personal projects

Expected Output

A step-by-step guide with commented code, concept explanations, a working CRUD API, and Postman test requests.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Ajoute un middleware d'erreur global `(err, req, res, next) => {}` dès le début. Cela évite de répéter try/catch sur chaque route et centralise les réponses d'erreur avec des codes HTTP précis (201 pour création, 204 pour suppression). Teste chaque endpoint avec Thunder Client et vérifie les en-têtes `Content-Type`.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementAdvancedAll AIs

Implement canary deployments

Roll out changes safely with canary

492
💻DeveloppementIntermediateAll AIs

Design a Complete REST API

Design a robust and well-structured REST API with OpenAPI documentation, error handling, and security best practices.

846

Implement Clean Architecture in Practice

Implement Clean Architecture in practice with layers, ports and adapters, use cases, and unit tests without infrastructure.

883
💻DeveloppementIntermediateAll AIs

Sora Prompt for Generating a Database Schema

Sora, the visual generation model developed by OpenAI, offers interesting possibilities for creating visual representations of database schemas. Instead of working with traditional technical tools like dbdiagram.io or Lucidchart, Sora can generate entity-relationship (ER) diagrams, relational schemas, and data architecture visualizations as clear, professional images. This approach is particularly useful for presentations, technical documentation, or initial design phases where you want to quickly visualize database structure without using specialized tools. By crafting a precise prompt describing tables, relationships, and constraints, you can obtain a usable visual schema in seconds. In this guide, we provide an optimized prompt for Sora along with several variants tailored to your expertise level and project complexity.

531