Skip to content

Commit

Permalink
Rename Place to Code
Browse files Browse the repository at this point in the history
PR-URL: #1879
  • Loading branch information
tshemsedinov committed Jul 30, 2023
1 parent aabe347 commit e604137
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/place.js → lib/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -70,4 +70,4 @@ class Place extends Cache {
}
}

module.exports = { Place };
module.exports = { Code };
6 changes: 3 additions & 3 deletions test/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions test/place.js → test/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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');
Expand Down

0 comments on commit e604137

Please sign in to comment.