dhbw 03-04 (node.js basics+advanced): cjs → esm in code-beispielen (import + node:-präfix), legacy-cjs als vergleichsbeispiel markiert, einheitliche cover, font 1.7→1.4rem, fragen-slides raus, __dirname/__filename via import.meta.url
This commit is contained in:
@@ -17,7 +17,7 @@ section.invert {
|
||||
--color-foreground: #fff;
|
||||
}
|
||||
section {
|
||||
font-size: 1.7rem;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
h1 {
|
||||
color: #005f8a;
|
||||
@@ -50,7 +50,30 @@ a {
|
||||
<!-- _header: '' -->
|
||||
<!-- _backgroundColor: #001520 -->
|
||||
|
||||
# node.js – Advanced
|
||||
# Web Engineering
|
||||
|
||||
**DHBW Stuttgart** · Informatik / Wirtschaftsinformatik
|
||||
|
||||
**Sommersemester 2026** · Sitzung 5 — Express API, CRUD und Middlewares
|
||||
|
||||
---
|
||||
|
||||
# Inhalt
|
||||
|
||||
1. Node.js — Fun Facts & alternative Runtimes
|
||||
2. `process` — Signal-Handling, Graceful Shutdown
|
||||
3. Express — Setup, Routing
|
||||
4. Middlewares (eigene + built-in)
|
||||
5. CRUD-Endpunkte (Create, Read, Update, Delete)
|
||||
6. Error Handling
|
||||
7. WebSockets
|
||||
|
||||
---
|
||||
|
||||
<!-- _class: invert -->
|
||||
<!-- _backgroundColor: #001520 -->
|
||||
|
||||
# Node.js – Advanced
|
||||
|
||||
---
|
||||
|
||||
@@ -87,14 +110,20 @@ process.exit(1); // Fehler
|
||||
# node.js Module System
|
||||
|
||||
```javascript
|
||||
// ES Modules
|
||||
import express from 'express';
|
||||
import { port } from './src/config/constants.js';
|
||||
|
||||
// CommonJS
|
||||
const fs = require('fs');
|
||||
// ES Modules (modern, "type": "module")
|
||||
import express from "express";
|
||||
import { port } from "./src/config/constants.js";
|
||||
import { readFileSync } from "node:fs";
|
||||
```
|
||||
|
||||
```javascript
|
||||
// CommonJS (legacy)
|
||||
const express = require("express");
|
||||
const fs = require("fs");
|
||||
```
|
||||
|
||||
→ Neue Projekte: ESM. Built-ins immer mit `node:`-Präfix.
|
||||
|
||||
---
|
||||
|
||||
# HTTP Request mit node-fetch
|
||||
@@ -249,10 +278,3 @@ wss.on('connection', (ws) => {
|
||||

|
||||
|
||||
|
||||
---
|
||||
|
||||
# Fragen?
|
||||
|
||||
1. Wozu dient `process.on('SIGINT')`?
|
||||
2. Was macht `app.use(express.json())`?
|
||||
3. Wie erstellst du einen GET-Endpoint mit Express?
|
||||
Reference in New Issue
Block a user