Horumarinta Backend
Tallaabo 7 / 20150 daqiiqo

Express & REST

APIs

Sharaxaad

Express wuxuu habeeyaa routes iyo middleware si aad u dhisto CRUD APIs HTTP cad.

Tusaale code

javascript
import express from "express";

const app = express();
app.use(express.json());
const skills = [{ id: "1", name: "HTTP" }];

app.get("/api/skills", (_req, res) => res.json(skills));
app.post("/api/skills", (req, res) => {
  const skill = { id: String(Date.now()), name: req.body.name };
  skills.push(skill);
  res.status(201).json(skill);
});

app.listen(4000);

Agab waxtar leh

Layli

Dhis GET list, GET by id, POST, PATCH, iyo DELETE ururinta resources.