mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-19 22:58:32 -05:00
dev: add services property to extensions
A small change that adds ".services" to the "extension" global in an extension, so extensions can more easily talk to other services.
This commit is contained in:
@@ -61,6 +61,17 @@ class Extension extends AdvancedBase {
|
||||
return db;
|
||||
}
|
||||
|
||||
get services () {
|
||||
const services = this.service.values.get('services');
|
||||
if ( ! services ) {
|
||||
throw new Error(
|
||||
'extension tried to access "services" before it was ' +
|
||||
'initialized'
|
||||
);
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will create a GET endpoint on the default service.
|
||||
* @param {*} path - route for the endpoint
|
||||
|
||||
@@ -80,6 +80,8 @@ class ExtensionService extends BaseService {
|
||||
}
|
||||
async _init (args) {
|
||||
this.state = args.state;
|
||||
|
||||
this.state.values.set('services', this.services);
|
||||
|
||||
// Create database access object for extension
|
||||
const db = this.services.get('database').get(DB_WRITE, 'extension');
|
||||
|
||||
Reference in New Issue
Block a user