Skip to content

Commit 75544b5

Browse files
committed
perf: add express server for efficient loading
1 parent 881a20b commit 75544b5

File tree

4 files changed

+1017
-406
lines changed

4 files changed

+1017
-406
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Music Blocks, using `cd path/to/musicblocks/`.
105105
4. After cloning the musicblocks repository, you can start a local server using npm
106106

107107
```bash
108-
npm run serve
108+
npm run dev
109109
```
110110

111111
6. You should see a message `Serving HTTP on 127.0.0.1 port 3000

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const express = require('express');
2+
const compression = require('compression');
3+
const path = require('path');
4+
5+
const app = express();
6+
7+
// Enable compression for all responses
8+
app.use(compression({
9+
level: 9,
10+
threshold: 0
11+
}));
12+
13+
app.use(express.static(path.join(__dirname), {
14+
maxAge: '1h'
15+
}));
16+
17+
const PORT = 3000;
18+
app.listen(PORT, '127.0.0.1', () => {
19+
console.log(`Music Blocks running at http://127.0.0.1:${PORT}/`);
20+
console.log('Compression enabled');
21+
});

0 commit comments

Comments
 (0)