mirror of
https://github.com/HeyPuter/puter.git
synced 2026-02-22 06:30:00 -06:00
dev: add apps module, migrate AppInformationService
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -373,7 +373,6 @@ 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 ===
|
||||
@@ -381,7 +380,6 @@ const install_legacy = async ({ services }) => {
|
||||
services.registerService('operationTrace', OperationTraceService);
|
||||
services.registerService('file-cache', FileCacheService);
|
||||
services.registerService('client-operation', ClientOperationService);
|
||||
services.registerService('app-information', AppInformationService);
|
||||
services.registerService('engineering-portal', EngPortalService);
|
||||
|
||||
};
|
||||
|
||||
@@ -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
src/backend/src/modules/apps/AppsModule.js
Normal file
14
src/backend/src/modules/apps/AppsModule.js
Normal file
@@ -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
|
||||
};
|
||||
Reference in New Issue
Block a user