diff --git a/lib/application.js b/lib/application.js index c7ff5eee..8c2b81d0 100644 --- a/lib/application.js +++ b/lib/application.js @@ -4,7 +4,7 @@ const { node, npm, metarhia, wt } = require('./deps.js'); const { MessageChannel, parentPort, threadId, workerData } = wt; const { Error, DomainError } = metarhia.metautil; const { Api } = require('./api.js'); -const { Place } = require('./place.js'); +const { Code } = require('./code.js'); const { Static } = require('./static.js'); const { Cert } = require('./cert.js'); const { Schemas } = require('./schemas.js'); @@ -52,10 +52,10 @@ class Application extends node.events.EventEmitter { this.cert = new Cert('cert', this, { ext: ['pem', 'domains'] }); this.resources = new Static('resources', this); this.api = new Api('api', this); - this.lib = new Place('lib', this); - this.db = new Place('db', this); - this.bus = new Place('bus', this); - this.domain = new Place('domain', this); + this.lib = new Code('lib', this); + this.db = new Code('db', this); + this.bus = new Code('bus', this); + this.domain = new Code('domain', this); this.starts = []; this.config = null; @@ -120,7 +120,7 @@ class Application extends node.events.EventEmitter { async stopPlace(name) { if (!this.sandbox) return; - const place = this.sandbox[name]; + const place = this[name]; for (const moduleName of Object.keys(place)) { const module = place[moduleName]; if (typeof module.stop === 'function') await this.execute(module.stop); diff --git a/lib/place.js b/lib/code.js similarity index 97% rename from lib/place.js rename to lib/code.js index bb9fecc9..02bac5b6 100644 --- a/lib/place.js +++ b/lib/code.js @@ -4,7 +4,7 @@ const { metarhia } = require('./deps.js'); const { Cache } = require('./cache.js'); const bus = require('./bus.js'); -class Place extends Cache { +class Code extends Cache { constructor(place, application) { super(place, application); this.tree = {}; @@ -70,4 +70,4 @@ class Place extends Cache { } } -module.exports = { Place }; +module.exports = { Code }; diff --git a/test/application.js b/test/application.js index 4548af9f..441cb1ad 100644 --- a/test/application.js +++ b/test/application.js @@ -20,9 +20,9 @@ metatests.test('lib/application', (test) => { test.strictSame(application.cert.constructor.name, 'Cert'); test.strictSame(application.resources.constructor.name, 'Static'); test.strictSame(application.api.constructor.name, 'Api'); - test.strictSame(application.lib.constructor.name, 'Place'); - test.strictSame(application.db.constructor.name, 'Place'); - test.strictSame(application.bus.constructor.name, 'Place'); + test.strictSame(application.lib.constructor.name, 'Code'); + test.strictSame(application.db.constructor.name, 'Code'); + test.strictSame(application.bus.constructor.name, 'Code'); test.strictSame(application.starts, []); test.strictSame(application.config, null); test.strictSame(application.logger, null); diff --git a/test/bus.js b/test/bus.js index 08366d2a..b347b4f1 100644 --- a/test/bus.js +++ b/test/bus.js @@ -2,7 +2,7 @@ const path = require('node:path'); const metatests = require('metatests'); -const { Place } = require('../lib/place.js'); +const { Code } = require('../lib/code.js'); const root = process.cwd(); @@ -17,7 +17,7 @@ const application = { }; metatests.testAsync('lib/bus', async (test) => { - const bus = new Place('bus', application); + const bus = new Code('bus', application); test.strictSame(bus.place, 'bus'); test.strictSame(bus.path, path.join(root, 'test/bus')); test.strictSame(typeof bus.application, 'object'); diff --git a/test/place.js b/test/code.js similarity index 86% rename from test/place.js rename to test/code.js index 5f9c1a4d..882b3f0e 100644 --- a/test/place.js +++ b/test/code.js @@ -2,7 +2,7 @@ const path = require('node:path'); const metatests = require('metatests'); -const { Place } = require('../lib/place.js'); +const { Code } = require('../lib/code.js'); const root = process.cwd(); @@ -16,8 +16,8 @@ const application = { }, }; -metatests.testAsync('lib/place', async (test) => { - const cache = new Place('cache', application); +metatests.testAsync('lib/code', async (test) => { + const cache = new Code('cache', application); test.strictSame(cache.place, 'cache'); test.strictSame(typeof cache.path, 'string'); test.strictSame(typeof cache.application, 'object');