Last active
August 21, 2025 13:59
-
-
Save krnlde/53a2dbf4891902006de9d129ccafc575 to your computer and use it in GitHub Desktop.
Express.js streaming static file server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import express from 'express'; | |
| import serveIndex from 'serve-index'; | |
| const PUBLIC_DIR = '/public'; | |
| const PORT = 3000; | |
| const app = express(); | |
| app.use(express.static(PUBLIC_DIR), serveIndex(PUBLIC_DIR, { 'icons': true })); | |
| app.listen(PORT, () => { | |
| console.log(`Server is listening on http://localhost:${PORT}/`); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "type": "module", | |
| "scripts": { | |
| "start": "node index.mjs", | |
| "up": "ncu --interactive --removeRange" | |
| }, | |
| "dependencies": { | |
| "express": "5.1.0", | |
| "npm-check-updates": "18.0.2", | |
| "serve-index": "1.9.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment