Skip to content

Commit

Permalink
perf: add express server for efficient loading
Browse files Browse the repository at this point in the history
  • Loading branch information
apsinghdev committed Feb 16, 2025
1 parent ec1a8f3 commit 62397de
Show file tree
Hide file tree
Showing 4 changed files with 1,042 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Music Blocks, using `cd path/to/musicblocks/`.
4. After cloning the musicblocks repository, you can start a local server using npm

```bash
npm run serve
npm run dev
```

6. You should see a message `Serving HTTP on 127.0.0.1 port 3000
Expand Down
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const express = require('express');
const compression = require('compression');
const path = require('path');

const app = express();

// Enable compression for all responses
app.use(compression({
level: 9,
threshold: 0
}));

app.use(express.static(path.join(__dirname), {
maxAge: '1h'
}));

const PORT = 3000;
app.listen(PORT, '127.0.0.1', () => {
console.log(`Music Blocks running at http://127.0.0.1:${PORT}/`);
console.log('Compression enabled');
});
Loading

0 comments on commit 62397de

Please sign in to comment.