Actionhero is a realtime multi-transport nodejs API Server with integrated cluster capabilities and delayed tasks
APACHE-2.0 License
Bot releases are visible (Hide)
Published by evantahler about 9 years ago
There was a bug in FakeRedis which caused newly generated projects to fail. FakeRedis package updated with the fix.
Published by evantahler about 9 years ago
api.connections.apply
would fail.
Published by evantahler about 9 years ago
Allow folks to optionally enable GZIP/Deflate compression for actionhero/servers/web. This can now be toggled on/off with api.config.servers.web.compress
. While this option exists, it is still best-practice to have an upstream process handle compression rather than node, like Nginx or a load balancer.
When enabled, if the client indicates they can handle compressed responses (via the Content-Encoding
header, we support gzip
and deflate
), Actionhero will compress results before sending the data over http. This decrease the network payload at the expense of both server and client CPU time.
By @evantahler via https://github.com/evantahler/actionhero/pull/689
Published by evantahler about 9 years ago
We have replaced the node-redis
package with ioredis
. This new redis package is mostly api compatible with node-redis, but adds support for sentinel and cluster out of the box. It is also faster is most cases.
./config/redis
for more informationIn certain cases (perhaps streaming behind a load balancer) you many not be able to obtain both the connection.ip
and connection.port
for connecting clients. You can now toggle off this requirement with api.config.general.enforceConnectionProperties
. Keep in mind that you may have trouble identifying and accessing unique connections with this option disabled.
The api.stats
module was very rarely used, so we removed it! This will reduce make actionhero a little bit leaner. If you want to continue to use api.stats
, you can access it via a plugin: https://github.com/evantahler/ah-stats-plugin. Keep in mind that some of the core loggers (like number of active connections, actions, etc) have been removed. You can re-implement them via middleware and plugins.
Published by evantahler about 9 years ago
node-resque
package, which now has helpers to allow for running jobs on a schedule (like CRON).Published by evantahler about 9 years ago
grunt console
more stablePublished by evantahler about 9 years ago
Error
object responses from your actions are serialized (probably into strings). Each web server has a matching method in api.config.errors.serializers[serverName]
which returns the response type
/config/errors.js
file in existing prjects to include the new errorSerializers object, as the error config cannot be merged with actionhero's internal defaults.Published by evantahler about 9 years ago
grunt console
: https://github.com/evantahler/actionhero/commit/294a134c19d64bd6d01f259723ba93c4ca06c7a5
Published by evantahler over 9 years ago
connection.action
for http/ws clients.data.error
can be inspectedclient.action("myAction", {thing: 'stuff'}, function(response){
if(response.error){
// ...
}else{
// ...
}
});
Published by evantahler over 9 years ago
onSayReceive
middleware. This will let you inspect/modify the message once (as it is sent in) rather than the say
middleware which will be invoked once per client connected to the room. In many cases, this might be more efficient.Published by evantahler over 9 years ago
Add the license to package.json
Published by evantahler over 9 years ago
say
Published by evantahler over 9 years ago
api.config.logger.maxLogStringLength
can now be used to truncate the length of params logged for actionsapi.actionProcessor.prototype.logAction
can now be monkeypatched for custom loggers of your actions (useful if your actions accept binary data!)
connection.fingerprint
of the HTTP connection that spawned the request (this was really hard!)
Published by evantahler over 9 years ago
apiVersion
in your route definations if you want to point a route to a specific version of an actionprocess.env.ACTIONHERO_SHUTDOWN_TIMEOUT
is an integer when passed on the command linePublished by evantahler over 9 years ago
Clients which use say
in chat rooms will now receive the message they send back in the normal broadcast way. This allows clients to display messages "you sent" if they wish. If you wish to ignore messages "you sent", simply don't show messages where client.id === message.from
.
Published by evantahler over 9 years ago
Implement new methods from https://github.com/taskrabbit/node-resque which make it easier to manage failed resque jobs:
failedCount
is how many resque jobs are in the failed queue.failedJobs
is an array listing the data of the failed jobs. You can see an example at https://github.com/taskrabbit/node-resque#failed-job-managment
failedJob
is an expanded node object representing the failed job, retrieved via api.tasks.failed
failedJob
is an expanded node object representing the failed job, retrieved via api.tasks.failed
Published by evantahler over 9 years ago
This allows us to remove the notion of connection._originalConnection
from actions/middleware. This simplifies (and speeds up) the code and allows for the expected behavior of modifying data.connection
within actions & middleware to persist.
!! This PR drastically changes the APIs of actions and middleware (breaking changes!). !!
Action Syntax now looks like this:
run: function(api, data, next){
data.response.randomNumber = Math.random();
next(error);
}
Where data contains:
data = {
connection: connection,
action: 'randomNumber',
toProcess: true,
toRender: true,
messageCount: 123,
params: { action: 'randomNumber', apiVersion: 1 },
actionStartTime: 123,
response: {},
}
Now, when you run an action, you modify data.response
. If there is an error, you callback to next(err)
with it.
If you don't want to toRender
, just set it to false: data.toRender = false
within the action.
When building custom servers, the response to an action is now:
server.on('actionComplete', function(data){
completeResponse(data);
});
Where data is the same as in the action. Note that data.toRender
should be inspected here. Any errors will be located in data.response.error
.
Similar to actions, the syntax becomes:
api.actions.addPreProcessor(function(data, next){
if(data.params.userId == null){
var error = new Error( "All actions require a userId" );
next(error);
}else{
next();
}
});
This will solve https://github.com/evantahler/actionhero/issues/561
By @evantahler via https://github.com/evantahler/actionhero/pull/615
Action middleware syntax is now:
api.actions.addMiddleware(definition);
// I.E.
api.actions.addMiddleware({
name: 'userId checker',
global: false,
priority: 1000,
preProcessor: function(data, next){
if(!data.params.userId){
next(new Error('All actions require a userId') );
}else{
next(err);
}
}
postProcessor: function(data, next){
if(data.thing.stuff == false){
data.toRender = false;
}
next(err);
}
});
definition.global = true
action.middleware
array where names of actions are supplied which are to be invoked by each action, ie:exports.randomNumber = {
name: 'randomNumber',
description: 'I am an API method which will generate a random number',
outputExample: {
randomNumber: 0.123
},
middleware: [ 'userId checker' ]
run: function(api, data, next){
data.response.randomNumber = Math.random();
next(null);
}
};
Connection middleware syntax is now:
api.connections.addMiddleware(definition);
// I.E.
api.connections.addMiddleware({
name: 'connection middleware',
priority: 1000,
create: function(connection){
// do stuff
},
destroy: function(connection){
// do stuff
}
});
by @evantahler via https://github.com/evantahler/actionhero/pull/625
api.chatRoom.addMiddleware(definition);
// I.E.
api.connections.addMiddleware({
name: 'connection middleware',
priority: 1000,
join: function(connection, room, callback){
// do stuff
callback(err);
},
leave: function(connection, room, callback){
// do stuff
callback(err);
},
say: function(connection, room, messagePayload, callback){
// do stuff
callback(err, messagePayload);
}
});
connection.params = {}
.by @evantahler via https://github.com/evantahler/actionhero/pull/629
var error = {error: true, message: 'something went wrong', code: 123};
next(error);
by @evantahler via https://github.com/evantahler/actionhero/pull/624
Published by evantahler over 9 years ago
webAction()
so that HTTP clients (or not-yet-connected websocket clients) can use complex object payload (switching from GET to POST).
api.commands.stop()
)
Published by evantahler over 9 years ago
clientJsName
is null
node-resque
and istanbul
packages to latest versions