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

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.

100% found this useful

Personalize this prompt with Léa

Answer 3 questions and Léa tailors the prompt to your situation.

Why this prompt works

<p>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.</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 pooling and migrations would be overwhelming. This gradation allows mastering each concept before introducing a new one.</p><p>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.</p>

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

💻DeveloppementIntermediateAll AIs

Implement secrets management

Secure credentials management

085
💻DeveloppementIntermediateGemini

Gemini Prompt for Creating a Chatbot

Gemini, Google's artificial intelligence model, offers remarkable capabilities for designing high-performance chatbots tailored to your needs. Whether you want to create a customer assistant for your e-commerce site, a technical support bot or a conversational companion, Gemini excels at understanding natural language nuances and generating contextual responses. Thanks to its extended context window and multimodal capability, Gemini enables building chatbots that can process text, images and even documents. The main challenge lies in the quality of the initial prompt that will define your chatbot's personality, tone, limits and skills. A well-structured prompt transforms Gemini into a true conversational architect, capable of generating the code, dialogue flows and business logic needed. In this guide, we offer optimized prompts to get the most out of Gemini when creating chatbots, from rapid prototyping to production deployment with error handling and advanced customization.

0124
💻DeveloppementBeginnerAll AIs

Documenting existing code

Quickly documenting existing undocumented code

097
💻DeveloppementAdvancedAll AIs

Plan a disaster recovery strategy

Plan DR for production systems

084