Add movie collection API and frontend

Express app with an in-memory array as the store (no database) and three
endpoints:

- GET  /api/movies      -> the whole collection
- GET  /api/movies/:id  -> one movie, 404 when the id is unknown
- POST /api/movies      -> add a movie, id assigned by the server

zod schemas are the single source of truth for validation, so a missing
title, genre or year comes back as a 400 with one message per field.
index.html is served by the same app and drives all three endpoints with
fetch(), refreshing the list after a movie is added.
This commit is contained in:
2026-09-21 14:51:55 +08:00
parent 2885727eb2
commit 6d00bb3cd1
6 changed files with 2152 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
# dev
.yarn/
!.yarn/releases
.vscode/*
!.vscode/launch.json
!.vscode/*.code-snippets
.idea/workspace.xml
.idea/usage.statistics.xml
.idea/shelf
# deps
node_modules/
# env
.env
.env.production
# logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
# misc
.DS_Store