Create your first API with Express.js
Learn to create your first Express.js REST API from A to Z with educational explanations adapted for beginners.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un formateur en développement web bienveillant et pédagogue, spécialisé dans l'enseignement de Node.js à des débutants. Je débute en développement backend et je veux créer ma première API avec Express.js. **Mon niveau actuel :** - Connaissance JavaScript : [EX: bases (variables, fonctions, boucles), intermédiaire (async/await, destructuring)] - Expérience backend : [EX: aucune, ou j'ai fait quelques scripts Node.js] - IDE utilisé : [EX: VS Code] **Ce que je veux créer :** [EX: une API de gestion de tâches (todo list), une API de blog, une API pour gérer des contacts] Guide-moi étape par étape pour créer cette API en expliquant chaque concept de manière simple : 1. **Setup du projet** : initialisation npm, installation d'Express et des dépendances essentielles (nodemon, dotenv), structure de dossiers. 2. **Premiers concepts Express** : explique req, res, next avec des analogies simples. Crée les premières routes GET et POST. 3. **CRUD complet** : implémente les 4 opérations (Create, Read, Update, Delete) avec les méthodes HTTP appropriées. 4. **Base de données simple** : utilise d'abord un tableau en mémoire, puis migre vers une base de données SQLite ou JSON avec explications. 5. **Validation basique** : valide les entrées utilisateur avant de les traiter. 6. **Test avec Thunder Client ou Postman** : fournis les requêtes de test pour chaque endpoint. 7. **Erreurs courantes** : liste les 5 erreurs les plus fréquentes des débutants et comment les éviter. Utilise des commentaires abondants dans le code et des explications en français accessible.
Why this prompt works
<p>This prompt is calibrated for beginners through several key elements: the request for explanations with simple analogies, using in-memory storage first before a real database (reducing initial complexity), and the list of common errors as prevention.</p><p>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, pool and migrations would be overwhelming. This gradation allows mastering each concept before introducing a new one.</p><p>The request for ready-to-use Postman/Thunder Client queries 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.</p>
Use Cases
Expected Output
A step-by-step guide with commented code, concept explanations, functional CRUD API and Postman test requests.
Learn more
Check the full skill on Prompt Guide to master this technique from A to Z.
View on Prompt GuideGlossary Terms
Similar Prompts
Learn the basics of Git for beginners
Learn Git from scratch with illustrated explanations, concrete examples, a practical workflow and a cheatsheet of essential commands.
Define a Git strategy for a team
Define a comprehensive Git strategy adapted to your team: branching model, conventions, code review and release management.
Write integration tests for an API
Create comprehensive API integration tests with database setup, authentication, CRUD and end-to-end scenarios.
Create an optimized Dockerfile for production
Create an optimized multi-stage Dockerfile for production with maximum security, lightweight image and best practices.