feat: support canonical puter.js url in dev

This commit is contained in:
KernelDeimos 2024-07-07 20:45:02 -04:00
parent fdea7907be
commit fd41ae217c
2 changed files with 26 additions and 0 deletions

View File

@ -76,6 +76,13 @@ class SelfHostedModule extends AdvancedBase {
},
],
});
const { ServeSingleFileService } = require('./services/ServeSingeFileService');
services.registerService('__serve-puterjs-new', ServeSingleFileService, {
path: path_.resolve(__dirname,
'../../../src/puter-js/dist/puter.dev.js'),
route: '/puter.js/v2',
});
}
}

View File

@ -0,0 +1,19 @@
const BaseService = require("./BaseService");
class ServeSingleFileService extends BaseService {
async _init (args) {
this.route = args.route;
this.path = args.path;
}
async ['__on_install.routes'] () {
const { app } = this.services.get('web-server');
app.get(this.route, (req, res) => {
return res.sendFile(this.path);
});
}
}
module.exports = {
ServeSingleFileService,
};