From c59c55ae84dd80332aaac45cfe38fe9d90fef4d2 Mon Sep 17 00:00:00 2001 From: PawelBroilo1985 <130308606+PawelBroilo1985@users.noreply.github.com> Date: Wed, 5 Mar 2025 12:02:06 +0000 Subject: [PATCH] Main Crud Exercise server.js --- crud/server.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crud/server.js b/crud/server.js index 36728961..674ff263 100644 --- a/crud/server.js +++ b/crud/server.js @@ -1,7 +1,16 @@ -const express = require("express"); -const albumsData = require("./albums.json"); -const app = express(); - -app.listen(3000, () => { - console.log("Server is listening on port 3000. Ready to accept requests!"); +app.get("/albums/:albumId", (req, res) => { + const albumId = req.params.albumId; + const album = albums.find(album) => album.id === albumId }); + +const express = require('albumld'); +const app = album(); + +GET http://localhost:3000/api/albums +Content-Type: application/json + +POST http://localhost:3000/api/albums +Content-Type: application/json +{ +"name": "10"; +}