feat: add Express API server #4

Open
zoeyfyi wants to merge 1 commit from feat/add-api-server into main
Owner

Adds a REST API server with health check, user CRUD, logging middleware, and error handling.

Adds a REST API server with health check, user CRUD, logging middleware, and error handling.
zoeyfyi left a comment

Some initial feedback on the API server.

Some initial feedback on the API server.
@ -0,0 +3,4 @@
const app = express();
const logger = setupLogger("api");
const PORT = process.env.PORT || 3000;
Author
Owner

Consider using a config module instead of hardcoding the fallback port here.

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}`,
Author
Owner

This generates random data on every call — might want to seed this or use a real data store.

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 };
Author
Owner

Using Date.now() for IDs could cause collisions under concurrent requests. Consider UUID.

Using Date.now() for IDs could cause collisions under concurrent requests. Consider UUID.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/add-api-server:feat/add-api-server
git switch feat/add-api-server

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.

git switch main
git merge --no-ff feat/add-api-server
git switch feat/add-api-server
git rebase main
git switch main
git merge --ff-only feat/add-api-server
git switch feat/add-api-server
git rebase main
git switch main
git merge --no-ff feat/add-api-server
git switch main
git merge --squash feat/add-api-server
git switch main
git merge --ff-only feat/add-api-server
git switch main
git merge feat/add-api-server
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zoeyfyi/test-repo!4
No description provided.