actionhero

Actionhero is a realtime multi-transport nodejs API Server with integrated cluster capabilities and delayed tasks

APACHE-2.0 License

Downloads
14.5K
Stars
2.4K
Committers
127

Bot releases are hidden (Show)

actionhero - v14.0.10: Status Example and Fingerprints

Published by evantahler over 8 years ago

Fingerprints

  • Now every connection type/server will default to connection.fingerprint === connection.id unless otherwise specified (AKA: The Web Server). This will ensure that authentication schemes you build should work for all server types.
  • by @evantahler via https://github.com/evantahler/actionhero/pull/900

Status Action

  • The example status action which will ship with a newly generated actionhero project has been enhanced to report on memory consumption, requeue queue length, and the node.js process' event loop delay.
  • This status action is likely not to be appropriate for all deployments, but should serve a good example.
> curl "http:// localhost:8080/api/status"

{
  "nodeStatus": "Node Healthy",
  "problems": [],
  "id": "10.0.1.34",
  "actionheroVersion": "14.0.10",
  "uptime": 18863,
  "name": "actionhero",
  "description": "actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks",
  "version": "14.0.10",
  "consumedMemoryMB": 32.9,
  "eventLoopDelay": 0.009,
  "resqueTotalQueueLength": 1,
  "serverInformation": {
    "serverName": "actionhero",
    "apiVersion": "14.0.10",
    "requestDuration": 29,
    "currentTime": 1469219570931
  },
  "requesterInformation": {
    "id": "ff9a4d458b08c3f0488ac7ddba77f239bc56e824-4691655f-cc87-4504-baa1-04e9aa13117d",
    "fingerprint": "ff9a4d458b08c3f0488ac7ddba77f239bc56e824",
    "remoteIP": "127.0.0.1",
    "receivedParams": {
      "action": "status",
      "apiVersion": 1
    }
  }
}

Packages

  • should updated to version ^10.0.0

Bugs

actionhero - v14.0.9: Client JS Folder Creation

Published by evantahler over 8 years ago

Fix for lack of javascript folder under public

  • ActionHero updates actionheroClient.js/.min.js on boot, so many people opt not to check the whole folder into version control. This resulted in the javascript folder not existing on other systems, which caused the tests to fail. This is a simple fix to create the javascript folder if it doesn't exist.
  • by @krishnaglick via https://github.com/evantahler/actionhero/pull/892

Misc

  • The api.id will now be appended to log files via default. In older projects, you can update this behavior by changing the format of the timestamp option in your logger, I.E.:
// in config.js
return new (winston.transports.File)({
  filename: api.config.general.paths.log[0] + '/' + api.pids.title + '.log',
  level: 'info',
  timestamp: function(){ return api.id + ' @ ' + new Date().toISOString(); },
});

Packages

  • async updated to version 2.0
actionhero - v14.0.8: api.tasks.locks

Published by evantahler over 8 years ago

Resque Locks

Misc

  • ActionHero start/stop/restart messages have been homogenized at *** ActionHero VERB ***
  • Removed checking process.env.PWD as a possible source of the project's working directory at boot (see https://github.com/nodejs/node/issues/7545 for more information)
actionhero - v14.0.7: delQueue and queued

Published by evantahler over 8 years ago

Expose resque functions via api.tasks:

actionhero -

Published by evantahler over 8 years ago

actionhero - v14.0.5: api.tasks.stats

Published by evantahler over 8 years ago

api.tasks.stats

You can now inspect the stats form your resque cluster (failed, succeeded, etc). api.tasks.details has been extended to include the output of api.tasks.stats

Misc

  • node-resque updated to version 2.0.7
  • ESLint updated to version 3.0.0
actionhero - v14.0.4: Fix for symlinked plugins

Published by evantahler over 8 years ago

Bugs

  • [https://github.com/evantahler/actionhero/commit/8834ecb07090251b66530edad70122c0ba303ce0] Fixes a bug which prevented plugins from being fully loaded from symlinked directories
  • [https://github.com/evantahler/actionhero/commit/6b1486992a33ec15f04b1ef80362467cc3e7e277] Starting message for actionhero is now *** ActionHero Started*** rather than ***Server Started*** to remove confusion when running actionhero without any servers (or in console mode)
  • [https://github.com/evantahler/actionhero/commit/29fe1b7da4bc65f484850c7ef3875c593536e33c] Fixes ruby gem boot order for building static site (www.actionherojs.com)
actionhero - v14.0.3: link --overwriteConfig + bugs squashed

Published by evantahler over 8 years ago

Add overwriteConfig parameter to the link function

Bugs

  • [https://github.com/evantahler/actionhero/pull/884] We now properly enforce RFC-compliant date headers for Last-Modified file headers. If you run actionhero on a computer where English or a western-style calendar is not your default locale, the format of Date().toString() might not be compliant. Strict checks for this were introduced in node v4.3.0. More detail here http://www.alexkras.com/typeerror-the-header-content-contains-invalid-characters
  • [https://github.com/evantahler/actionhero/commit/4e2d3a8fca1fa95ce863caff86d71a89bcac1770] Task error reporter now properly returns local worker's ID
  • [https://github.com/evantahler/actionhero/commit/4ab8730bb3a05429bbdd6ab36d14a22837902a2e] ws package upgraded to fix security issues
  • [https://github.com/evantahler/actionhero/commit/7fa75383f106b06e6e57fbcb9c9c357e1536a800] Ruby gem and version upgrade for static site (www.actionherojs.com) generator to fix ruby security issues
actionhero - v14.0.2: Better redis config

Published by evantahler over 8 years ago

Better redis config

actionhero - v14.0.1: Better redis config

Published by evantahler over 8 years ago

VERSION REMOVED

Better redis config

actionhero - v14.0.0: Redis Config and Named Validators & Formatters

Published by evantahler over 8 years ago

Named Validators & Formatters

Allows for action validators and formatters to use both named methods and direction functions.

exports.cacheTest = {
  name: 'cacheTest',
  description: 'I will test the internal cache functions of the API',
  outputExample: {},

  inputs: {
    key: {
      required: true,
      formatter: [
         function(s){ return String(s); },
         'api.formatter.uniqueKeyName' // <----------- HERE
    },
    value: {
      required: true,
      formatter: function(s){ return String(s); },
      validator: function(s){
        if(s.length < 3){ return '`value` should be at least 3 letters long'; }
        else{ return true; }
      }
    },
  },

  run: function(api, data, next){
    // ...
  }

};

And then you would define an initializer with your formatter:

'use strict';

module.exports = {
  initialize: function(api, next){
    api.formatter = {
      uniqueKeyName: function(key){
        return key + '-' + this.connection.id;
      }
    };

    next();
  },
};

Redis Client

There are so many ways to configure redis these days... handling the config options for all of them (sentinel? cluster?) is a pain... so lets just let the users configure things directly. It will be so much simpler!

This will be a breaking change

  • in config/redis.js, you now define the 3 redis connections you need explicitly rather than passing config options around:
var host     = process.env.REDIS_HOST || '127.0.0.1';
var port     = process.env.REDIS_PORT || 6379;
var database = process.env.REDIS_DB   || 0;

exports['default'] = {
  redis: function(api){
    var Redis = require('ioredis');

    return {
      '_toExpand': false,
      // create the redis clients
      client:     Redis.createClient(port, host),
      subscriber: Redis.createClient(port, host),
      tasks:      Redis.createClient(port, host),
    };
  }
};

  • move api.config.redis.channel to api.config.general.channel
  • move api.config.redis. rpcTimeout to api.config.general. rpcTimeout
  • throughout the code, use api.config.redis.client rather than api.redis.client
actionhero - v13.4.4: Minor Package Updates

Published by evantahler over 8 years ago

  • new ENV flag ENABLE_TCP_SERVER to enable TCP (port 5000) at boot
  • minor updates to internal boot order of initializers.
  • i18n updated to 0.8.3
  • ioredis updated to 2.1.0
  • uglify-js updated to 2.6.4
actionhero - v13.4.3: Cleanup

Published by evantahler over 8 years ago

Load apiVersion and serverName from package.json

In new projects, we will load api.config.general.apiVersion and api.config.general.serverName from the equivalent fields in package.json, rather than need to re-define them in various config files.

Electron support and log directory fix

There's was a bug in Electron causing directory listing of an ASAR subdirectory to return a listing of the ASAR root, when the path to list has a trailing slash. To fix:

Packages

  • Primus updated to v5.2.2
actionhero - v13.4.2: Unlink and ETags

Published by evantahler over 8 years ago

ActionHero Unlink

  • Just like we have actionhero link to enable a plugin... we now have actionhero unlink to remove that plugin!
  • From the help:
Will remove the linked actions, tasks, initializers, etc from a plugin in your top-level project. 
Please remove the config files manually. 
Remember if your plugin was installed via NPM, also be sure to remove it from your package.json or uninstall it with npm uninstall --save

Etags

  • Actionhero now responds with E-Tags when returning static files (or connection.sendFile() from an action). ETags are a header technology which enables browser to ask if an asset has changed by sending a SHA of the last version of the file they have, and asking the server if there is an update. This can reduce the network load of you server significantly.
  • There is a new option, api.config.servers.web.enableEtag to enable this feature, defaulting to true.
  • By @S3bb1 via https://github.com/evantahler/actionhero/pull/862

Misc

  • Cleanup sending cache-contol, Expires, and Last-Modified Headers if we are returning a 404 for a file request
  • Removed api.utils.hashLength, as it was unused. User Object.keys(item).length if you need this functionality.
  • fix api.task.details, which was broken by a previous release.
  • Typos in docs fixed by @krishnaglick

Package Updates

  • ESLint: v2.11.0
  • IORedis: v2.0.0
  • Should: v9.0.1
actionhero - v13.4.1: bugs, docker, and localization

Published by evantahler over 8 years ago

Web Server File Sending Memory Leak fix

When sending files via HTTP in ActionHero, we make use of pipes to efficiently stream files to clients, ie: fs.createReadStream(file).pipe(response). We noticed that if your ActionHero sends a lot of files, it was possible to end up with a memory leak, as a growing number of connections would remain in RAM as they were still denoted as "sending data", even when they might not be.

We use the request.finish() even to clean up the connection, and this worked well 99% of the time. However, if there was an issue with the transfer (premature client hangup, networking error, etc), that finish event would never be called. We now also listen for a close event, which catches these error cases.

api.chatRoom.list

Tasks: Bring your own workers

Extending/modifying the functionality of Resque within ActionHero has been cumbersome and has made upgrading deployments troublesome. We now have a new section in config/tasks.js to allow developers to replace the existing queues, scheduler, and multiWorkers with custom implementations.

For Example:

'use strict';

var NR = require('node-resque');
var pluginRunner = require('../node_modules/node-resque/lib/pluginRunner.js');

//noinspection JSUnresolvedVariable
module.exports = {
  loadPriority:  590,
  initialize: function(api, next){
    api.customResque = {};

    let customQueue = NR.queue;

    customQueue.prototype.enqueueFront = function(q, func, args, callback){
      var self = this;
      if(arguments.length === 3 && typeof args === 'function'){
        callback = args;
        args = [];
      }else if(arguments.length < 3){
        args = [];
      }

      args = arrayify(args);
      var job = self.jobs[func];
      pluginRunner.runPlugins(self, 'before_enqueue', func, q, job, args, function(err, toRun){
        if(toRun === false){
          if(typeof callback === 'function'){ callback(err, toRun); }
        }else{
          self.connection.redis.sadd(self.connection.key('queues'), q, function(){
            self.connection.redis.lpush(self.connection.key('queue', q), self.encode(q, func, args), function(){
              pluginRunner.runPlugins(self, 'after_enqueue', func, q, job, args, function(){
                if(typeof callback === 'function'){ callback(err, toRun); }
              });
            });
          });
        }
      });
    };

    api.customResque.queue = customQueue;

    next();
  }
};

Localization Updates

  • Added a general localization helper via api.i18n.localize(string, options) or api.i18n.localize([string-with-interpolation, value], options).
  • Localized the chat room errors
  • Localized the cache errors
  • by @l0oky via https://github.com/evantahler/actionhero/pull/837

Docker Example

  • Created a docker image (evantahler/actionhero) which will auto-build from master and contain a sample actionhero project from the latest public NPM version
FROM alpine:3.3
MAINTAINER [email protected]

RUN apk add --update nodejs
RUN npm install actionhero
RUN ./node_modules/.bin/actionhero generate
RUN npm install

CMD ["node", "./node_modules/.bin/actionhero", "start"]
EXPOSE 8080 5000

Fixed direct access of servers via api.servers.servers

Misc

  • use a much simpler publication method to build and publish www.actionhero.com; remove submodule dependency from the project.
  • eslint updated to v2.10.0
  • should updated to v8.3.2
  • mocha updated to v2.5.1
  • node-resque updated to v2.0.5
  • misc test updates which will hopefully make Travis.ci happier, and report less intermittent failures.
actionhero - v13.4.0: Slack + Static assets in routes

Published by evantahler over 8 years ago

Community -> Slack

  • We now use slack for the Actionhero community, and have shut-down our old Gitter room.
  • Anyone can join our new Slack team... please do! Visit slack.actionherojs.com to get started!

Map static folders in routes.js

You can now map a folder like this:

get: [
  { path: '/my/special/folder', dir: __dirname + '/../my/special/folder', matchTrailingPathParts: true }
],

and access all files under the given "dir" path within the mapped path.

Misc

  • We now test on node versions 4,5, and 6 on Travis.ci. Actionhero works on them all! Yay!
  • Under the hood cleanup to use the async package more (clean up some gnarly old looping code)
  • Under the hood cleanup to use "error" rather than "err" for clarity
  • Primus updated to v5.2.1
actionhero - v13.3.3

Published by evantahler over 8 years ago

Dynamic line delimiter and maxDataLength (Socket Server)

  • added a api.config.servers.socket.delimiter option to the socket server so you can change from \n being the line delimiter.
  • adding a api.config.servers.socket.maxDataLength option to the socket server to prevent buffer overflows with long data submissions
  • By @l0oky via https://github.com/evantahler/actionhero/pull/824

Expose matched route to Connection

  • now you can check data.connection.matchedRoute to see the details of the route that got the web connection to this action... if in case a route was matched via the router.
data.connection.matchedRoute = { 
  path: '/mimeTestAction/:key',
  matchTrailingPathParts: false,
  action: 'mimeTestAction'
 }

Generator

Documentation Updates

actionhero - v13.3.2

Published by evantahler over 8 years ago

Localized goodbyeMessage for socket clients

You can now configure the message the server sends to connections on the socket server type with api.config.servers.socket.goodbyeMessage. This string can be localized.

Documentation updates.

Thanks to @krishnaglick, @iSimar, @peterlandry, and @evantahler for their work keeping out documentation up to date!

Misc

  • Updated ioredis to the latest version
actionhero - v13.3.1: Link Fixes

Published by evantahler over 8 years ago

Link Fixes

Fix a bug that prevented actionhero link from working when config files were in nested directories within plugins, ie: plugin/config/server/myServer.js

Templates and Linting

actionhero - v13.3.0: Strict.

Published by evantahler over 8 years ago

Strict Mode:

We now enforce javasctipt's strict mode (via 'use strict';) at the top of most Actionhero files. This enables easier opt-in to new ES6 features, and will help catch errors which might sneak by otherwise. You should notice no change in Actionhero's behavior. Newly generated files (Actions, Tasks, etc) will also contain the line 'use strict'; at the top of each file, but you can remove it if you don't want strict mode for some reason.

You can learn more about strict mode here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

null HTTP Headers

You can now set some of the default HTTP headers to null if you don't want them returned to the client. For example, if you no longer want to send Access-Control-Allow-Origin, you can do the following in config/servers/web.js:

exports.production = { 
  servers: {
    web: function(api){
      return {
        httpHeaders : {
          'Access-Control-Allow-Origin' : null,
        },
      }
    }
  }
}

Misc