<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Boutheina Remadi</title>
    <description>The latest articles on Forem by Boutheina Remadi (@boutheina_remadi_99138387).</description>
    <link>https://forem.com/boutheina_remadi_99138387</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2114643%2F9b306187-0e1a-49f2-acf6-1c5a19f7c6dd.png</url>
      <title>Forem: Boutheina Remadi</title>
      <link>https://forem.com/boutheina_remadi_99138387</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/boutheina_remadi_99138387"/>
    <language>en</language>
    <item>
      <title>Creating a Node.js API with Express (Students Example)</title>
      <dc:creator>Boutheina Remadi</dc:creator>
      <pubDate>Thu, 08 Jan 2026 19:40:55 +0000</pubDate>
      <link>https://forem.com/boutheina_remadi_99138387/creating-a-nodejs-api-with-express-students-example-f5p</link>
      <guid>https://forem.com/boutheina_remadi_99138387/creating-a-nodejs-api-with-express-students-example-f5p</guid>
      <description>&lt;p&gt;Introduction&lt;br&gt;
In this article, we will build a simple Node.js API using Express.&lt;br&gt;
The goal is not to create a complex application, but to understand the basic structure of a professional backend.&lt;/p&gt;

&lt;p&gt;This example will later be extended for an educational platform, where students can study law and social sciences.&lt;/p&gt;

&lt;p&gt;Technologies Used&lt;br&gt;
Node.js&lt;/p&gt;

&lt;p&gt;Express&lt;/p&gt;

&lt;p&gt;CORS&lt;/p&gt;

&lt;p&gt;JSON&lt;/p&gt;

&lt;p&gt;A database connection (abstracted for now)&lt;/p&gt;

&lt;p&gt;Project Structure&lt;br&gt;
Here is a minimal and scalable project structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fah75cxgmtb4yttco7rf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fah75cxgmtb4yttco7rf1.png" alt=" " width="271" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This structure helps keep the code clean and easy to maintain.&lt;/p&gt;

&lt;p&gt;🧩 Express Server Code&lt;/p&gt;

&lt;p&gt;Below is the main file of our Express application:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgkny7k7oo3f0mzdqmj5q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgkny7k7oo3f0mzdqmj5q.png" alt=" " width="773" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code Explanation&lt;br&gt;
1️⃣ Express Initialization&lt;br&gt;
const app = express();&lt;/p&gt;

&lt;p&gt;This creates an Express application instance.&lt;/p&gt;

&lt;p&gt;2️⃣ Middleware Configuration&lt;br&gt;
app.use(cors());&lt;/p&gt;

&lt;p&gt;Middleware Configuration&lt;br&gt;
app.use(cors());&lt;br&gt;
app.use(express.json());&lt;br&gt;
CORS allows requests from external frontends.&lt;/p&gt;

&lt;p&gt;express.json() enables the server to read JSON request bodies.&lt;br&gt;
3️⃣ Database Connection&lt;br&gt;
connectDB();&lt;/p&gt;

&lt;p&gt;This function connects the application to a database when the server starts.&lt;/p&gt;

&lt;p&gt;Students API Routes&lt;br&gt;
app.use("/api/students", studentsRouter);&lt;/p&gt;

&lt;p&gt;All student-related routes are available under:&lt;/p&gt;

&lt;p&gt;GET /api/students&lt;/p&gt;

&lt;p&gt;POST /api/students&lt;/p&gt;

&lt;p&gt;GET /api/students/:id&lt;br&gt;
PUT /api/students/:id&lt;/p&gt;

&lt;p&gt;DELETE /api/students/:id&lt;/p&gt;

&lt;p&gt;This follows REST API best practices.&lt;br&gt;
Starting the Server&lt;br&gt;
app.listen(5000, () =&amp;gt;&lt;br&gt;
  console.log("API running on &lt;a href="http://localhost:5000%22" rel="noopener noreferrer"&gt;http://localhost:5000"&lt;/a&gt;)&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;The server runs on port 5000.&lt;br&gt;
Why This Setup Is a Good Starting Point&lt;/p&gt;

&lt;p&gt;✔️ Clean and readable&lt;br&gt;
✔️ Beginner-friendly&lt;br&gt;
✔️ Easy to extend&lt;br&gt;
✔️ Frontend-agnostic&lt;br&gt;
✔️ Suitable for educational projects&lt;/p&gt;

&lt;p&gt;What’s Next?&lt;/p&gt;

&lt;p&gt;In the next articles, we will:&lt;/p&gt;

&lt;p&gt;implement full CRUD operations for students&lt;/p&gt;

&lt;p&gt;connect a real database&lt;/p&gt;

&lt;p&gt;add courses and legal references&lt;/p&gt;

&lt;p&gt;build an educational library&lt;/p&gt;

&lt;p&gt;secure the API&lt;br&gt;
✨ Conclusion&lt;/p&gt;

&lt;p&gt;With just a few lines of code, we have created a solid Express backend foundation.&lt;br&gt;
This setup is perfect for learning Node.js and building real-world projects step by step.&lt;br&gt;
📌 Follow the series&lt;/p&gt;

&lt;p&gt;More tutorials coming soon 🚀&lt;/p&gt;

</description>
      <category>api</category>
      <category>javascript</category>
      <category>node</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
