mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 22:40:20 +08:00
refactor: move FilesystemService to BaseService
This commit is contained in:
parent
3e98f1a8a8
commit
360ad2e252
@ -156,6 +156,16 @@ const install = async ({ services, app, useapi }) => {
|
||||
MaxLimitES, { max: 5000 },
|
||||
]),
|
||||
});
|
||||
|
||||
const { ParameterService } = require('./services/ParameterService');
|
||||
services.registerService('params', ParameterService);
|
||||
|
||||
const { InformationService } = require('./services/information/InformationService');
|
||||
services.registerService('information', InformationService)
|
||||
|
||||
const { FilesystemService } = require('./filesystem/FilesystemService');
|
||||
services.registerService('filesystem', FilesystemService);
|
||||
|
||||
services.registerService('es:subdomain', EntityStoreService, {
|
||||
entity: 'subdomain',
|
||||
upstream: ESBuilder.create([
|
||||
@ -263,9 +273,7 @@ const install = async ({ services, app, useapi }) => {
|
||||
|
||||
const install_legacy = async ({ services }) => {
|
||||
const { ProcessEventService } = require('./services/runtime-analysis/ProcessEventService');
|
||||
const { ParameterService } = require('./services/ParameterService');
|
||||
const { InformationService } = require('./services/information/InformationService');
|
||||
const { FilesystemService } = require('./filesystem/FilesystemService');
|
||||
// const { FilesystemService } = require('./filesystem/FilesystemService');
|
||||
const PerformanceMonitor = require('./monitor/PerformanceMonitor');
|
||||
const { OperationTraceService } = require('./services/OperationTraceService');
|
||||
const { WSPushService } = require('./services/WSPushService');
|
||||
@ -277,9 +285,7 @@ const install_legacy = async ({ services }) => {
|
||||
|
||||
// === Services which do not yet extend BaseService ===
|
||||
services.registerService('process-event', ProcessEventService);
|
||||
services.registerService('params', ParameterService);
|
||||
services.registerService('information', InformationService)
|
||||
services.registerService('filesystem', FilesystemService);
|
||||
// services.registerService('filesystem', FilesystemService);
|
||||
services.registerService('operationTrace', OperationTraceService);
|
||||
services.registerService('__event-push-ws', WSPushService);
|
||||
services.registerService('referral-code', ReferralCodeService);
|
||||
|
@ -38,8 +38,9 @@ const { PermissionUtil, PermissionRewriter, PermissionImplicator, PermissionExpl
|
||||
const { DB_WRITE } = require("../services/database/consts");
|
||||
const { UserActorType } = require('../services/auth/Actor');
|
||||
const { get_user } = require('../helpers');
|
||||
const BaseService = require('../services/BaseService');
|
||||
|
||||
class FilesystemService extends AdvancedBase {
|
||||
class FilesystemService extends BaseService {
|
||||
static MODULES = {
|
||||
_path: require('path'),
|
||||
uuidv4: require('uuid').v4,
|
||||
@ -47,11 +48,11 @@ class FilesystemService extends AdvancedBase {
|
||||
config: require('../config.js'),
|
||||
}
|
||||
|
||||
constructor (args) {
|
||||
super(args);
|
||||
old_constructor (args) {
|
||||
// super(args);
|
||||
const { services } = args;
|
||||
|
||||
this.services = services;
|
||||
// this.services = services;
|
||||
|
||||
services.registerService('resourceService', ResourceService);
|
||||
services.registerService('sizeService', SizeService);
|
||||
@ -101,13 +102,10 @@ class FilesystemService extends AdvancedBase {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: eventually FilesystemService will extend BaseService
|
||||
// and _init() will be called (and awaited) automatically
|
||||
this._init();
|
||||
}
|
||||
|
||||
async _init () {
|
||||
this.old_constructor({ services: this.services });
|
||||
const svc_permission = this.services.get('permission');
|
||||
svc_permission.register_rewriter(PermissionRewriter.create({
|
||||
matcher: permission => {
|
||||
|
@ -1,3 +1,5 @@
|
||||
const BaseService = require("./BaseService");
|
||||
|
||||
/*
|
||||
* Copyright (C) 2024 Puter Technologies Inc.
|
||||
*
|
||||
@ -16,12 +18,13 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
class ParameterService {
|
||||
constructor({ services }) {
|
||||
this.log = services.get('log-service').create('params');
|
||||
class ParameterService extends BaseService {
|
||||
_construct () {
|
||||
this.parameters_ = [];
|
||||
|
||||
this._registerCommands(services.get('commands'));
|
||||
}
|
||||
|
||||
_init () {
|
||||
this._registerCommands(this.services.get('commands'));
|
||||
}
|
||||
|
||||
createParameters(serviceName, parameters, opt_instance) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
const BaseService = require("../BaseService");
|
||||
|
||||
/*
|
||||
* Copyright (C) 2024 Puter Technologies Inc.
|
||||
*
|
||||
@ -77,19 +79,13 @@ class InformationObtainer {
|
||||
* // code to obtain fsentry from path
|
||||
* });
|
||||
*/
|
||||
class InformationService {
|
||||
constructor ({ services }) {
|
||||
class InformationService extends BaseService {
|
||||
_construct () {
|
||||
this.providers_ = {};
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
this.log = services.get('log-service').create('information-service');
|
||||
|
||||
(async () => {
|
||||
await services.ready;
|
||||
if ( services.has('commands') ) {
|
||||
this._register_commands(services.get('commands'));
|
||||
}
|
||||
})();
|
||||
_init () {
|
||||
this._register_commands(this.services.get('commands'));
|
||||
}
|
||||
|
||||
given (input) {
|
||||
|
Loading…
Reference in New Issue
Block a user