Skip to content

Commit fd41ae2

Browse files
committed
feat: support canonical puter.js url in dev
1 parent fdea790 commit fd41ae2

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/backend/src/SelfHostedModule.js

+7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ class SelfHostedModule extends AdvancedBase {
7676
},
7777
],
7878
});
79+
80+
const { ServeSingleFileService } = require('./services/ServeSingeFileService');
81+
services.registerService('__serve-puterjs-new', ServeSingleFileService, {
82+
path: path_.resolve(__dirname,
83+
'../../../src/puter-js/dist/puter.dev.js'),
84+
route: '/puter.js/v2',
85+
});
7986
}
8087
}
8188

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const BaseService = require("./BaseService");
2+
3+
class ServeSingleFileService extends BaseService {
4+
async _init (args) {
5+
this.route = args.route;
6+
this.path = args.path;
7+
}
8+
async ['__on_install.routes'] () {
9+
const { app } = this.services.get('web-server');
10+
11+
app.get(this.route, (req, res) => {
12+
return res.sendFile(this.path);
13+
});
14+
}
15+
}
16+
17+
module.exports = {
18+
ServeSingleFileService,
19+
};

0 commit comments

Comments
 (0)