Create a small Node.js + static frontend project in /app/ that demonstrates server-side PNG metadata extraction and a static viewer. Use Node (v14) and yarn; add any npm dependencies via yarn.
Requirements
Project layout (all files must be created under /app/):
package.json with scripts:
"start": starts the server (node server.js)
"install": normal install via yarn (yarn will be used)
server.js: an Express server that:
Serves static files from /app/public at root (so visiting / serves index.html)
Exposes GET /api/images which:
Reads all .png files from /app/public/images
For each PNG, reads the file and computes its width and height using the pngjs package (do not invoke external binaries; use the pngjs npm package)
Listen on port 3000 (configurable via PORT env var)
/app/public/index.html and /app/public/app.js:
index.html should load app.js
app.js should fetch GET /api/images and render a simple HTML list/grid showing each image (using the url field), and its filename and dimensions
/app/public/images: create two small sample PNG files (they can be generated in a small Node script or written from base64 strings). They must be valid PNGs so the server can parse them.
Use yarn to install dependencies (express and pngjs). Ensure package.json lists them so running yarn in /app will install them.
No Dockerfile edits. The solution must live in /app/.
Response should be a JSON array of objects containing filename, width, height, and url for each PNG in public/images.
Example response:
[
{"filename":"a.png","width":1,"height":1,"url":"/images/a.png"},
{"filename":"b.png","width":16,"height":16,"url":"/images/b.png"}
]
Open http://localhost:3000/ in a browser (or curl the HTML) and you should see the two images and their dimensions displayed.
Additional notes / constraints
The server-side PNG dimension extraction must use the npm package pngjs (or another pure-JS PNG parser). Do not shell out to external tools or rely on system libraries for PNG decoding.
The frontend must be static files served from /app/public (no React or build step required).
Keep code simple and well-organized. Place all project files inside /app/.