Express is a Node.js framework for building a small REST backend with minimal configuration. It creates an HTTP server, maps routes, returns JSON, and can serve frontend files. section 7.1
A minimal Express backend follows these implementation steps:
- Install the dependency with npm install express. section 7.1
- Create an application, define GET /contents, and return stored data with response.json. section 7.1
- Start the server on port 8080 and verify it at http://localhost:8080/contents. section 7.1
- Serve the frontend dist/ directory as static content so frontend and backend share an origin. section 7.1
JSON backend for a rental AST
A storage module reads and writes contents.json. Express exposes the stored rental example through GET /contents, while the frontend fetches that endpoint and renders the returned JSON. section 7.1
Listing 7.4 Code to start an Express server in src/backend/server.js
const { readContents } = require("./storage") #1
let contents = readContents()
const express = require("express") #2
const server = express() #3
server.get("/contents", (request, response) => { #4
response.json(contents)
})
// TODO add PUT code #5
// TODO add static serving code
const port = 8080
server.listen(port, () => { #6
console.log(`Server started on: http://localhost:${port}`)
})
Inspect the complete server setup, including storage loading, the JSON route, the port, and placeholders for future PUT and static-serving code. section 7.1



