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.

Personalize this prompt with Léa

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

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

Perplexity Prompt for Creating a Software Architecture

Perplexity stands out as a particularly powerful tool for software architecture design thanks to its ability to synthesize recent and verified technical sources. Unlike a classic LLM that relies solely on its training data, Perplexity queries the web in real time to integrate the latest best practices, emerging architectural patterns, and community feedback. Whether you are designing a microservices architecture, a modular monolith, or an event-driven system, a well-structured prompt allows you to obtain contextualized recommendations with verifiable sources. The challenge is to provide enough business and technical context for Perplexity to cross-reference relevant information: technology stack, scalability constraints, infrastructure budget, and team skills. By phrasing your request precisely, you transform Perplexity into a true consultant architect capable of proposing component diagrams, reasoned technology choices, and deployment strategies tailored to your specific context.

475
💻DeveloppementAdvancedAll AIs

Kubernetes Backup Strategy

Kubernetes Disaster Recovery Plan

324
💻DeveloppementIntermediateAll AIs

Adapting an API for Different Clients

Tailoring API responses to client needs

371
💻DeveloppementAdvancedAll AIs

Implement cost optimization with Terraform

Reduce cloud infrastructure costs

369