This commit is contained in:
+51
-16
@@ -430,41 +430,76 @@ Projekte
|
||||
|
||||
---
|
||||
|
||||
#### TBA
|
||||
|
||||
**Inhalt:**
|
||||
|
||||
- **Exkurs: Gulp vs Vite**
|
||||
- CRUD - Create - Read - Update - Delete
|
||||
- Object Methoden.
|
||||
- Verwendung von Modulen (Bootstrap)
|
||||
|
||||
**Übungen:**
|
||||
|
||||
Projekte & optionale Übungen
|
||||
## BROWSER API
|
||||
|
||||
---
|
||||
|
||||
#### Tag 29
|
||||
#### Tag 26
|
||||
|
||||
**Inhalt:**
|
||||
|
||||
- **Exkurs: DOM Inhalte über mit REST API Express**
|
||||
- **Erweiterung Frontend um REST API**
|
||||
- CRUD - Create - Read - Update - Delete
|
||||
- CRUD - (Create - Read) - Update - Delete
|
||||
- BREAD - Browse - Read - Edit - Add - Delete
|
||||
- Verwendung von Modulen (Modal von BS, Toastify, Splide)
|
||||
|
||||
**Übungen**
|
||||
|
||||
Projekte + weiteres Modul einbinden
|
||||
Projekte & optionale Übungen
|
||||
|
||||
---
|
||||
|
||||
#### Tag 30
|
||||
#### Tag 27
|
||||
|
||||
- **Exkurs: Vite vs Gulp**
|
||||
- **SASS 7 on 1 mit Bootstrap 6**
|
||||
- **Projektfinalisierung Express + REST API**
|
||||
- Einführung in Typescript
|
||||
|
||||
|
||||
---
|
||||
|
||||
### Tag 28
|
||||
|
||||
**Inhalt:**
|
||||
|
||||
- Typescript Grundlagen
|
||||
- Typescript Annotationen
|
||||
- Typescript "more Types"
|
||||
|
||||
**Übungen:**
|
||||
|
||||
Übungen 1 - 5
|
||||
|
||||
---
|
||||
|
||||
### Tag 29
|
||||
|
||||
**Inhalt:**
|
||||
|
||||
- Typescript Annotationen
|
||||
- Primitive Types, Object, Union Types
|
||||
- type statement vs interface
|
||||
- Type Assertion with as and <>
|
||||
- Typescript "more Types"
|
||||
|
||||
**Übungen:**
|
||||
|
||||
Übungen 4 - 9
|
||||
|
||||
---
|
||||
|
||||
### Tag 30
|
||||
|
||||
**Inhalt:**
|
||||
|
||||
- Typescript "more Types"
|
||||
- Interface, as statement, literale
|
||||
- Typescript Narrowing with Guards
|
||||
- truthiness, equality, in-operator, type-predicate
|
||||
- TS Funktionen und Objekte
|
||||
|
||||
**Übungen:**
|
||||
|
||||
Übungen 10 - 19
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# BROWSE Products
|
||||
|
||||
GET http://127.0.0.1:8000/api/products
|
||||
|
||||
###
|
||||
|
||||
# READ Product
|
||||
|
||||
GET http://127.0.0.1:8000/api/products/174a2a19-26eb-475e-af47-4f46d2ab62ec
|
||||
|
||||
###
|
||||
|
||||
# ADD Product
|
||||
|
||||
POST http://127.0.0.1:8000/api/products
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "Testproduct",
|
||||
"price": 9.99
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
|
||||
@@ -29,10 +29,24 @@ const ProductModel = () => {
|
||||
return product;
|
||||
};
|
||||
|
||||
const add = (product) => {
|
||||
const { name, price } = product;
|
||||
|
||||
products.push({
|
||||
_id: id(),
|
||||
position: products.length + 1,
|
||||
name,
|
||||
price: Number(Number(price).toFixed(2)),
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
return {
|
||||
load,
|
||||
getAll,
|
||||
get,
|
||||
add,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ products.load();
|
||||
|
||||
const app = express();
|
||||
// Middleware =======
|
||||
// app.use(express.static('./public'));
|
||||
app.use(express.static('./public'));
|
||||
app.use(express.json()); // => HTTP-Request Body wird als JSON Objekt erwartet und geparsed. // app.use(bodyParser.json()) - Module: body-parser war in express 4 notwendig.
|
||||
|
||||
// Routes ===========
|
||||
|
||||
@@ -25,18 +26,40 @@ const app = express();
|
||||
// PUT/PATCH - Daten aktualisieren /Datensatz aktualisieren
|
||||
// DELETE - Daten löschen
|
||||
|
||||
// HTTP - Methode - POST
|
||||
// (C)RUD - create
|
||||
// BRE(A)D - add
|
||||
app.post('/api/products', (req, res) => {
|
||||
const product = req.body;
|
||||
|
||||
if (!products.add(product)) {
|
||||
return res.status(400).send({ msg: 'Could not add product', status: 400, success: false });
|
||||
}
|
||||
|
||||
return res.send({ msg: 'Product added', status: 200, success: true, data: product });
|
||||
});
|
||||
|
||||
// HTTP - Methode - GET
|
||||
// C(R)UD - read
|
||||
// (B)READ - browse
|
||||
app.get('/api/products', (req, res) => {
|
||||
const data = products.getAll();
|
||||
res.send(data);
|
||||
return res.send(data);
|
||||
});
|
||||
|
||||
// HTTP - Methode - GET
|
||||
// C(R)UD - read
|
||||
// B(R)EAD - read
|
||||
app.get('/api/products/:id', (req, res) => {
|
||||
const { id } = req.params;
|
||||
const data = products.get(id);
|
||||
return res.send(data);
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Server is running!');
|
||||
return res.send('Server is running!');
|
||||
});
|
||||
|
||||
app.get('/persons', (req, res) => {
|
||||
@@ -49,7 +72,7 @@ app.get('/persons', (req, res) => {
|
||||
// ]),
|
||||
// );
|
||||
|
||||
res.send([
|
||||
return res.send([
|
||||
{ firstName: 'Max', lastName: 'Mustermann' },
|
||||
{ firstName: 'John', lastName: 'Wick' },
|
||||
]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Meeting Fr. 09.10.2026
|
||||
|
||||
- [ ] Benjamin 14:30 - 14:40
|
||||
- [ ] Florian 14:40 - 14:50
|
||||
- [ ] Christian 14:50 - 15:00
|
||||
- [ ] Stefan 15:00 - 15:10
|
||||
- [x] Benjamin 14:35 - 14:45
|
||||
- [x] Florian 14:45 - 14:55
|
||||
- [x] Christian 14:55 - 15:05
|
||||
- [x] Stefan 15:05 - 15:15
|
||||
Reference in New Issue
Block a user