Socket
Socket
Sign inDemoInstall

impress

Package Overview
Dependencies
12
Maintainers
4
Versions
718
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.3 to 3.0.4

25

lib/application.js

@@ -5,3 +5,3 @@ 'use strict';

const { MessageChannel, parentPort, threadId, workerData } = wt;
const { Error, DomainError } = metarhia.metautil;
const { Error, DomainError, Semaphore } = metarhia.metautil;
const { Api } = require('./api.js');

@@ -45,2 +45,3 @@ const { Code } = require('./code.js');

const ERR_INIT = 'Can not initialize an Application';
const ERR_TEST = 'Application tests failed';

@@ -67,2 +68,3 @@ class Application extends node.events.EventEmitter {

this.starts = [];
this.tests = [];
this.config = null;

@@ -73,2 +75,4 @@ this.logger = null;

this.watcher = null;
this.semaphore = null;
this.mode = process.env.MODE || 'prod';
}

@@ -118,4 +122,19 @@

this.sandbox.application.emit('initialized');
if (this.mode === 'test' && threadId === 1) this.test();
const { concurrency, size, timeout } = this.config.server.queue;
this.semaphore = new Semaphore(concurrency, size, timeout);
}
async test() {
setTimeout(async () => {
await this.parallel(
this.tests.map((test) =>
node.test(test.name, (t) => this.execute(test.run, t)),
),
ERR_TEST,
);
process.kill(process.pid, 'SIGINT');
}, 1000);
}
async shutdown() {

@@ -166,4 +185,4 @@ this.finalization = true;

execute(method) {
return method().catch((error) => {
execute(method, ...args) {
return method(...args).catch((error) => {
const msg = `Failed to execute method: ${error?.message}`;

@@ -170,0 +189,0 @@ this.console.error(msg, error.stack);

@@ -67,3 +67,6 @@ 'use strict';

if (!filePath.endsWith('.js')) return;
if (filePath.startsWith('.eslint')) return;
const { application, path, name } = this;
const isTest = filePath.endsWith('.test.js');
if (isTest && application.mode !== 'test') return;
const options = { context: application.sandbox, filename: filePath };

@@ -75,2 +78,3 @@ try {

this.set(relPath, exp);
if (isTest) application.tests.push(exp);
} catch (error) {

@@ -77,0 +81,0 @@ if (error.code !== 'ENOENT') {

6

lib/procedure.js

@@ -43,3 +43,3 @@ 'use strict';

async enter() {
await this.application.server.semaphore.enter();
await this.application.semaphore.enter();
if (this.concurrency) {

@@ -49,3 +49,3 @@ try {

} catch (error) {
this.application.server.semaphore.leave();
this.application.semaphore.leave();
throw error;

@@ -57,3 +57,3 @@ }

leave() {
this.application.server.semaphore.leave();
this.application.semaphore.leave();
if (this.concurrency) this.semaphore.leave();

@@ -60,0 +60,0 @@ }

@@ -68,3 +68,3 @@ 'use strict';

const stat = await node.fsp.stat(absPath).catch(() => null);
if (!stat) return void transport.error(404);
if (!stat || !stat.isFile()) return void transport.error(404);
const { size } = stat;

@@ -78,5 +78,2 @@ const range = metarhia.metautil.parseRange(transport.req.headers.range);

const readable = node.fs.createReadStream(absPath, options);
readable.on('error', () => {
transport.error(404);
});
return void transport.write(readable, 206, fileExt, options);

@@ -83,0 +80,0 @@ }

{
"name": "impress",
"version": "3.0.3",
"version": "3.0.4",
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",

@@ -65,7 +65,7 @@ "description": "Enterprise application server for Node.js",

"dependencies": {
"metacom": "^3.0.2",
"metacom": "^3.0.5",
"metaconfiguration": "^2.1.11",
"metalog": "^3.1.12",
"metaschema": "^2.1.5",
"metautil": "^3.11.0",
"metautil": "^3.12.0",
"metavm": "^1.2.6",

@@ -72,0 +72,0 @@ "metawatch": "^1.1.1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc