Comparing version 2.0.0-alpha.39 to 2.0.0
# Changelog | ||
## [Unreleased][unreleased] - 2020-12-21 | ||
## [Unreleased][unreleased] | ||
To be released in 2.0.0 | ||
## [2.0.0][] - 2020-12-21 | ||
@@ -31,3 +31,4 @@ - Single application with code live reload and auto API routing | ||
[unreleased]: https://github.com/metarhia/impress/compare/v1.0.9...HEAD | ||
[unreleased]: https://github.com/metarhia/impress/compare/v2.0.0...HEAD | ||
[2.0.0]: https://github.com/metarhia/impress/compare/v1.0.9...v2.0.0 | ||
[1.0.9]: https://github.com/metarhia/impress/releases/tag/v1.0.9 |
@@ -20,2 +20,4 @@ 'use strict'; | ||
const SANDBOX = { ...metavm.COMMON_CONTEXT, Error, node, npm, metarhia }; | ||
class Application extends events.EventEmitter { | ||
@@ -27,2 +29,3 @@ constructor() { | ||
this.api = {}; | ||
this.signatures = {}; | ||
this.static = new Map(); | ||
@@ -82,29 +85,10 @@ this.resources = new Map(); | ||
const { server: { host, port, protocol } = {} } = this; | ||
const introspect = async (interfaces) => this.introspect(interfaces); | ||
const worker = { id: 'W' + node.worker.threadId.toString() }; | ||
const server = { host, port, protocol }; | ||
const application = { | ||
security, | ||
introspect, | ||
worker, | ||
server, | ||
auth, | ||
resources, | ||
}; | ||
const api = {}; | ||
const lib = {}; | ||
const domain = {}; | ||
const sandbox = { | ||
...metavm.COMMON_CONTEXT, | ||
Error, | ||
console, | ||
application, | ||
node, | ||
npm, | ||
metarhia, | ||
api, | ||
lib, | ||
domain, | ||
config, | ||
}; | ||
const application = { security, worker, server, auth, resources }; | ||
application.introspect = async (interfaces) => this.introspect(interfaces); | ||
const sandbox = { ...SANDBOX, console, application, config }; | ||
sandbox.api = {}; | ||
sandbox.lib = {}; | ||
sandbox.domain = {}; | ||
this.sandbox = metavm.createContext(sandbox); | ||
@@ -161,6 +145,25 @@ } | ||
methods[name] = script; | ||
internalInterface[name] = script(EMPTY_CONTEXT); | ||
const exp = script(EMPTY_CONTEXT); | ||
internalInterface[name] = exp; | ||
this.cacheSignature(iname + '.' + version, name, exp); | ||
if (version > iface.default) iface.default = version; | ||
} | ||
cacheSignature(interfaceName, methodName, exp) { | ||
let interfaceMethods = this.signatures[interfaceName]; | ||
if (!interfaceMethods) { | ||
interfaceMethods = {}; | ||
this.signatures[interfaceName] = interfaceMethods; | ||
} | ||
interfaceMethods[methodName] = this.getSignature(exp); | ||
} | ||
getSignature(exp) { | ||
const fn = typeof exp === 'object' ? exp.method : exp; | ||
const src = fn.toString(); | ||
const signature = common.between(src, '({', '})'); | ||
if (signature === '') return []; | ||
return signature.split(',').map((s) => s.trim()); | ||
} | ||
addModule(namespaces, exports, iface) { | ||
@@ -288,18 +291,3 @@ let level = this.sandbox; | ||
const version = ver === '*' ? iface.default : parseInt(ver); | ||
const methods = iface[version.toString()]; | ||
const methodNames = Object.keys(methods); | ||
const interfaceMethods = {}; | ||
intro[iname] = interfaceMethods; | ||
for (const methodName of methodNames) { | ||
const exp = methods[methodName](EMPTY_CONTEXT); | ||
const fn = typeof exp === 'object' ? exp.method : exp; | ||
const src = fn.toString(); | ||
const signature = common.between(src, '({', '})'); | ||
if (signature === '') { | ||
interfaceMethods[methodName] = []; | ||
continue; | ||
} | ||
const args = signature.split(',').map((s) => s.trim()); | ||
interfaceMethods[methodName] = args; | ||
} | ||
intro[iname] = this.signatures[iname + '.' + version]; | ||
} | ||
@@ -306,0 +294,0 @@ return intro; |
{ | ||
"name": "impress", | ||
"version": "2.0.0-alpha.39", | ||
"version": "2.0.0", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -43,3 +43,3 @@ "description": "Impress application server for Node.js and Metarhia private cloud", | ||
}, | ||
"homepage": "https://github.com/metarhia", | ||
"homepage": "https://metarhia.com", | ||
"funding": { | ||
@@ -64,3 +64,3 @@ "type": "patreon", | ||
"@metarhia/config": "^2.0.0", | ||
"metacom": "1.0.0-alpha.0", | ||
"metacom": "1.0.0", | ||
"metalog": "^3.0.0", | ||
@@ -67,0 +67,0 @@ "metavm": "^1.0.0" |
@@ -10,8 +10,18 @@ [![impress logo](http://habrastorage.org/files/d67/1b3/be5/d671b3be591d47a9bd10fe857e9d5319.png)](https://github.com/metarhia/impress) | ||
[Impress](https://github.com/metarhia/impress) Application Server for | ||
[node.js](http://nodejs.org). All decisions are made. Solutions are scaled and | ||
optimized for performance and load. | ||
[Impress](https://github.com/metarhia/impress) application server for | ||
[node.js](http://nodejs.org). All decisions are made and optimized for security, | ||
performance, high-intensive network operations, scalability, interactivity, rapid | ||
development practices, and clean project structure. | ||
Metarhia and Impress Application Server way: | ||
## Quick start | ||
- Install with `npm install impress` or copy project template from | ||
[metarhia/Example](https://github.com/metarhia/Example) | ||
- Start server with `node server.js` or select execution mode (test, dev, prod) | ||
use `MODE=dev node server.js` | ||
- See [documentation and specifications](https://github.com/metarhia/Contracts) | ||
and project home page: https://metarhia.com | ||
### Metarhia and Impress application server way | ||
- Applied code need to be simple and secure, so we use code sandboxing with v8 | ||
@@ -53,9 +63,2 @@ isolated contexts, worker threads and minimal trusted npm dependencies; | ||
## Installation, upgrade and start | ||
- Install with `npm install impress` | ||
- See project structure [Metarhia Starter Kit](https://github.com/metarhia/Example) | ||
- Start server with `npm run start` or `node server.js` | ||
- To select execution mode (test, dev, prod) use `MODE=dev node server.js` | ||
## Requirements | ||
@@ -62,0 +65,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
33001
0
80
735
+ Addedmetacom@1.0.0(transitive)
- Removedmetacom@1.0.0-alpha.0(transitive)
Updatedmetacom@1.0.0