Skip to content

Commit

Permalink
dev: add apps module, migrate AppInformationService
Browse files Browse the repository at this point in the history
There are now several services related to apps, and
RecommendedAppsService is about to be added, making this a good time to
create a separate module for these services and migrate the legacy
service AppInformationService.

During migration it was realized that most of the initialization needed
to occur at boot.consolidation rather than boot.init because the
database needs to be initialized first.
KernelDeimos committed Dec 30, 2024
1 parent 3ffb3cb commit 2de442b
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/backend/exports.js
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ const { Core2Module } = require("./src/modules/core/Core2Module.js");
const { TemplateModule } = require("./src/modules/template/TemplateModule.js");
const { PuterFSModule } = require("./src/modules/puterfs/PuterFSModule.js");
const { PerfMonModule } = require("./src/modules/perfmon/PerfMonModule.js");
const { AppsModule } = require("./src/modules/apps/AppsModule.js");


module.exports = {
@@ -53,6 +54,7 @@ module.exports = {
CoreModule,
WebModule,
TemplateModule,
AppsModule,
],

// Pre-built modules
2 changes: 0 additions & 2 deletions src/backend/src/CoreModule.js
Original file line number Diff line number Diff line change
@@ -373,15 +373,13 @@ const install_legacy = async ({ services }) => {
const { OperationTraceService } = require('./services/OperationTraceService');
const { ClientOperationService } = require('./services/ClientOperationService');
const { EngPortalService } = require('./services/EngPortalService');
const { AppInformationService } = require('./services/AppInformationService');
const { FileCacheService } = require('./services/file-cache/FileCacheService');

// === Services which do not yet extend BaseService ===
// services.registerService('filesystem', FilesystemService);
services.registerService('operationTrace', OperationTraceService);
services.registerService('file-cache', FileCacheService);
services.registerService('client-operation', ClientOperationService);
services.registerService('app-information', AppInformationService);
services.registerService('engineering-portal', EngPortalService);

};
Original file line number Diff line number Diff line change
@@ -19,10 +19,9 @@
*/
const { asyncSafeSetInterval } = require('@heyputer/putility').libs.promise;
const { MINUTE, SECOND } = require("@heyputer/putility").libs.time;
const { origin_from_url } = require("../util/urlutil");
const { DB_READ } = require("./database/consts");

const uuidv4 = require('uuid').v4;
const { origin_from_url } = require("../../util/urlutil");
const { DB_READ } = require("../../services/database/consts");
const BaseService = require('../../services/BaseService');


/**
@@ -35,15 +34,15 @@ const uuidv4 = require('uuid').v4;
* up-to-date information about applications, facilitating features like app listings,
* recent apps, and tag-based app discovery.
*/
class AppInformationService {
constructor ({ services }) {
this.services = services;
this.log = services.get('log-service').create('app-info');

class AppInformationService extends BaseService {
_construct () {
this.collections = {};
this.collections.recent = [];

this.tags = {};
}

['on_boot.consolidation'] () {

// MySQL date format mapping for different groupings
this.mysqlDateFormats = {
14 changes: 14 additions & 0 deletions src/backend/src/modules/apps/AppsModule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { AdvancedBase } = require("@heyputer/putility");

class AppsModule extends AdvancedBase {
async install (context) {
const services = context.get('services');

const { AppInformationService } = require('./AppInformationService');
services.registerService('app-information', AppInformationService);
}
}

module.exports = {
AppsModule
};

0 comments on commit 2de442b

Please sign in to comment.