feat: add Express API server #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/add-api-server"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds a REST API server with health check, user CRUD, logging middleware, and error handling.
Some initial feedback on the API server.
@ -0,0 +3,4 @@const app = express();const logger = setupLogger("api");const PORT = process.env.PORT || 3000;Consider using a config module instead of hardcoding the fallback port here.
@ -0,0 +21,4 @@const limit = parseInt(req.query.limit) || 10;const users = Array.from({ length: limit }, (_, i) => ({id: i + 1,name: `User ${i + 1}`,This generates random data on every call — might want to seed this or use a real data store.
@ -0,0 +32,4 @@if (!name || !email) {return res.status(400).json({ error: "Name and email required" });}const newUser = { id: Date.now(), name, email, active: true };Using Date.now() for IDs could cause collisions under concurrent requests. Consider UUID.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.