mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 23:28:39 +08:00
Add support for webhook endpoints
This commit is contained in:
parent
cc45a08388
commit
90463a0732
@ -51,7 +51,7 @@ class BaseService extends AdvancedBase {
|
||||
async __on (id, args) {
|
||||
const handler = this.__get_event_handler(id);
|
||||
|
||||
return await handler(id, args);
|
||||
return await handler(id, ...args);
|
||||
}
|
||||
|
||||
__get_event_handler (id) {
|
||||
|
@ -113,7 +113,7 @@ class Container {
|
||||
const promises = [];
|
||||
for ( const k in this.instances_ ) {
|
||||
if ( this.instances_[k].__on ) {
|
||||
promises.push(this.instances_[k].__on(id, ...args));
|
||||
promises.push(this.instances_[k].__on(id, args));
|
||||
}
|
||||
}
|
||||
await Promise.all(promises);
|
||||
|
@ -46,7 +46,10 @@ class WebServerService extends BaseService {
|
||||
const app = this.app;
|
||||
const services = this.services;
|
||||
await services.emit('install.middlewares.context-aware', { app });
|
||||
await services.emit('install.routes', { app });
|
||||
await services.emit('install.routes', {
|
||||
app,
|
||||
router_webhooks: this.router_webhooks,
|
||||
});
|
||||
await services.emit('install.routes-gui', { app });
|
||||
}
|
||||
|
||||
@ -123,7 +126,7 @@ class WebServerService extends BaseService {
|
||||
ports_to_try = null; // GC
|
||||
|
||||
const url = config.origin;
|
||||
|
||||
|
||||
this.startup_widget = () => {
|
||||
const link = `\x1B[34;1m${osclink(url)}\x1B[0m`;
|
||||
const lines = [
|
||||
@ -320,6 +323,11 @@ class WebServerService extends BaseService {
|
||||
}
|
||||
})
|
||||
|
||||
// Web hooks need a router that occurs before JSON parse middleware
|
||||
// so that signatures of the raw JSON can be verified
|
||||
this.router_webhooks = express.Router();
|
||||
app.use(this.router_webhooks);
|
||||
|
||||
app.use(express.json({limit: '50mb'}));
|
||||
|
||||
const cookieParser = require('cookie-parser');
|
||||
|
Loading…
Reference in New Issue
Block a user