Giter Club home page Giter Club logo

impress's Introduction

impress logo

TravisCI bitHound Codacy Badge NPM Version NPM Downloads/Month NPM Downloads

Impress Application Server for node.js. All decisions are made. Solutions are scaled. Tools are provided and optimized for high load. Ready for applied development and production.

Impress (Impress Application Server, IAS) follows alternative way in several aspects:

  • No middleware (avoid such evil as long callback chains);
  • Monolithic high cohesion core, must-have things optimized for performance;
  • Applied code simplicity, API code high-level abstraction and brevity;
  • Support for both Stateful and Stateless approach;
  • Extensible plug-ins system for optionally needed features;
  • Application can't include Application Server, quite the opposite, Application Server is a container for Applications;
  • No I/O is faster even then async I/O, so maximum memory usage and lazy I/O is the choice;

Features

  • Can serve multiple applications and sites on multiple domains;
  • Serves multiple ports, network interfaces, hosts and protocols;
  • Can scale on multiple servers;
  • Supports application sandboxing (configuration, db and memory access isolation);
  • Utilize multiple CPU cores with instances/workers:
    • Cross-process communication (not using built-in node.js cluster library);
    • State synchronization mechanism with transactions and subscription;
  • No need to write routing manually in code, just create handler files and functions;
  • File system watching for cache reloading when file changes on disk;
  • Cache server-side executable JavaScript in memory;
  • Handlers inheritance override hierarchically;
  • API development support (simple way for JSON-based WEB-services development):
    • RPC-style API (Stateful, state stored in memory between requests);
    • REST-style API (Stateless, each call is separate, no state in memory);
    • Implements JSTP (long live and full duplex RPC/MQ over TCP or websockets);
  • Multiple handlers for HTTP API (all handlers are optional and inheritable/overridable): access.js returns access modifiers; request.js executing for all requests (any HTTP verbs and before verb handler); HTTP verbs: get.js, post.js, etc. executes for certain HTTP verb,;end.js executes after HTTP verb handler for all verbs; lazy.js lazy handler executes after the request has already returned to the client-side; error.js executed only if an error occurred while processing the request or in any previous handler;
  • Supported multiple AJAX API result types: JSON for most APIs (including safe serialization); JSONP (for cross-domain requests); CSV; HTML (aor any extension unknown for IAS) for AJAX server-side HTML rendering; JSTP (for JavaScript Transfer Protocol);
  • Server-side simple templating with caching, data structures iterators and personalization based on user groups;
  • Serving static files with in-memory preprocessing: gzipping and HTTP if-modified-since support with HTTP 304 "Not Modified" answer; memory caching and file system watching for cache reloading when files changed on disk; JavaScript minification with uglify-js; SASS compiling styles from .scss to .css in memory cache;
  • Built-in sessions support with authentication, groups and anonymous sessions;
  • Multiple protocols support:
    • JSTP (JavaScript Transfer Protocol) for RPC and MQ; (https://github.com/metarhia/jstp);
    • HTTP and HTTPS (node native libraries);
    • Implemented SSE (Server-Sent Events) with channels and multi-cast;
    • WebSockets support;
    • TCP and UDP sockets support;
  • Reverse-proxy (routing request to external HTTP server with URL-rewriting);
  • Server-wide or application-specific logging, with log buffering (lazy write) and rotation (keep logs N days);
  • Connection drivers for database engines: MongoDB, PgSQL, MySQL, Relational schema generator from JSON database schemas;
  • File utilities: upload, download, streaming;
  • GeoIP support, based on geoip-lite module (uses MaxMind database);
  • Sending emails using nodemailer;
  • Built-in simple testing framework;
  • Server health monitoring;
  • Built-in data structures validation and preprocessing library;
  • Process forking:
    • Long workers with client object forwarding to separate process;
    • Task scheduling (interval or certain time);
  • V8 features support:
    • Long stack trace with --stack-trace-limit=1000 and stack output minification;
    • Wrapper for V8 internal functions with --allow-natives-syntax;
    • Manual garbage collection with --nouse-idle-notification and --expose-gc;
  • HTTP basic authentication implemented (optional omitting local requests);

Examples

Example #1
To create GET request handler for URL /api/method.json
File /api/method.json/get.js

(client, callback) => {
  callback({ field: 'value' });
}

Result: { "field": "value" }

Example #2
To create POST request handler for URL /api/method.json
File /api/method.json/post.js

(client, callback) => {
  dbImpress.users
  .find({ group: client.fields.group })
  .toArray((err, nodes) => callback(nodes));
}

Result:

[
  { "login": "Vasia Pupkin", "password": "whoami", "group": "users" },
  { "login": "Marcus Aurelius", "password": "tomyself", "group": "users" }
]

Example #3
File access.js works similar to .htaccess and allow one to define access rules for each folder, by simply putting access.js in it.
If folder does not contain access.js it inherits access rules from its parent folder, all the way up to the project root.

Example:

{
  guests:  true,  // Allow requests from anonymous (not logged) users
  logged:  true,  // Allow requests from logged users
  http:    true,  // Allow requests using http protocol
  https:   true,  // Allow requests using https protocol
  groups:  [],    // Allow access for user groups listed in array
                  //   or for all if array is empty or no groups specified
  intro:   true,  // Generate introspection for API in this directory
  index:   false, // Generate directory index
  virtual: true   // Allow requests to virtual paths, for CMS and REST URLs
}

Installation and upgrade

  • Install to the current folder: npm install impress
  • Install using package.json: add to dependencies and run npm install
  • Installation scripts for an empty server (from the scratch)
    • For CentOS 6 /deploy/centos6x32.sh and centos6x64.sh (tested on CentOS 6.6 32/64bit minimal)
    • For CentOS 7 /deploy/centos7x64.sh (tested on CentOS 7.0 with systemd 64bit minimal)
    • For Ubuntu 14 and 15 /deploy/ubuntu.sh (tested on Ubuntu 14.04 64bit minimal)
    • For Debian 7 and 8 /deploy/debian.sh (tested for Debian 7.5 64bit minimal)
    • For Fedora 22, 23, 24 and 25 for x64 /deploy/fedora.sh

You can prepare scripts based on examples above and run at a target server shell: curl http://.../install.sh | sh or wget http://.../install.sh -O - | sh

If Impress Application Server is already installed in directory you want to install/update it using npm, /applications directory contains applications and /config contains configuration, Impress will safely detect previous installation and update libraries and dependencies.

Impress CLI commands

You can use following commands from any directory:

  • impress path <path> to display or change path to IAS
  • impress start to start IAS server
  • impress stop to stop IAS server
  • impress restart to restart IAS server
  • impress status to display IAS status
  • impress update to update IAS version
  • impress autostart [on|off] to add/remove IAS to autostart on system reboot
  • impress list to see IAS applications list
  • impress add [path] to add application
  • impress remove [name] to remove application
  • impress new [name] to create application

Configuration

  1. Install Impress as described above
  2. Edit /config/*.js to configure Application Server (set IP address in servers.js)
  3. After installation you have example application in directory /applications, you can rename it and/or place there other applications
  4. Edit /applications/example/config/hosts.js, change 127.0.0.1 to myapp.com, certainly you need to register and configure domain name myapp.com or just add it into hosts file in your OS
  5. Place your html to /applications/example/app/html.template and copy required files into directories /static/js, /static/css, /static/images and start application API development
  6. Run Impress using command service impress start or systemctl start impress (if installed as a service) or node server.js

Contributors

License

Dual licensed under the MIT or RUMI licenses. Copyright (c) 2012-2017 Metarhia contributors. Project coordinator: <[email protected]>

RUMI License: Everything that you want, you are already that. // Jalal ad-Din Muhammad Rumi

impress's People

Contributors

alexxxtremer avatar aqrln avatar belochub avatar dehimer avatar dzyubspirit avatar j-martyn avatar johnbizokk avatar jwo1f avatar nechaido avatar o-rumiantsev avatar sensarg22 avatar skellla avatar streetstrider avatar tblasv avatar theelix avatar tshemsedinov avatar viktor-evdokimov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.