Category: node.JS

rss

Spludo 1.1.0 released

Finally a new spludo 1.1.0 release is available. This is also the start of 1.2-dev development.

The 1.1-branch will stay to support node version 0.4, 1.2 will (soon) support only 0.6 and later.

Changes from 1.0.3 to 1.1.0:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
* added dependency to node >=0.4.0 && node < 0.5.0
* generator for monit+upstart configuration
* code generation for migrations extended with shortcut fields definition
* added support for application/json paylod
* generate *ByIds method for services
* added ApiServiceController to register a service as REST service
* context.request now holds the current req instance
* added inflection.js
* added node_modules for own vendor libraries
* replaced own testing system with vows (if you want to run the tests, please install vows!)
* spludo_directory variable is now set always when calling spludo-gen
* added bootstrap_manager.whenLoaded(callback) to get notified as
soon as the app is ready.
* replaced self with that
* fixed core_dev_change_build_version on MACOSX
* added jshint instead of jslint
* added support for node_modules folder in project directory
* added Criteria for DatabaseDrivers
* added code generation for Migrations
* added SqliteDatabaseDriver
* added a Database Migration system
* added MysqlDatabaseDriver
* added code generation for Services
* added DatabaseManager and ServiceManager
* added Logging#addTracing (makes the this.trace(function_name) obsolete)
* Codegeneration loads the spludo application now (this enables the developer
to generate code against the base of the application)
* Codegeneration #validateParameter receives the validated parameters now
* TestCases are now able to call .debug+.log and so on, because the execute
method is applied to the TestSuite.

I have been using this development version for plenty small projects and the code generation, migrations and database driver stuff should really help
you get your app developed way faster!

Loads of documentation and examples can be found in the spludo user guide.

Have fun!

In open source, node.JS & Spludo By DracoBlue @ 13:00 20.11.2011

Nginx always overwrites the Server-Header

When I was configuring the nodejs server behind nginx, I experienced the issue that nginx always overwrote the Server header response.

This is a bit annoying, since I want to know what version of spludo runs on my site.

The solution is not to set

1
server_tokens off

since that would only disable the version number.

The solution is:

1
proxy_pass_header Server;
In node.JS, Spludo & NGINX By DracoBlue @ 22:08 19.06.2011

Facebook Client for node.js 1.3.0

Today I have an update for the Facebook Client for node.js finished.

The version 1.3.0 is a graph and rest api client for facebook. It has support for the latest stable nodejs 0.4.x.

Now it's possible to post data (for instance into your news feed):

1
2
3
4
5
6
7
8
facebook_session.graphCall(
"/me/feed", {
"message":"I love node.js!"
},
'POST'
)(function(result) {
console.log('The new feed post id is: ' + result.id);
});

All you need to do is to specify the method parameter (defaults to GET).

Thanks to jharlap for this addition.

Also thanks to tslater and shaisultanov. They found an issue with expires-time (which is fixed now) and requested the brand new FacebookSession#isValid method, which tells you if the session is really alive.

Source may be found at node-facebook-client@github.

The package is also available by using npm:

1
$ npm install facebook-client

log4j like logging in node.js (from Spludo)

One core feature of spludo, is the powerful logging system. This system is entirely independent from spludo, so you may use it in your own (even non-spludo) nodejs project with ease.

Like described in the tutorial about configuration, you can easily add logging facality to every prototyped class:

1
2
3
4
5
6
7
DocsManager = function() {
// ...
}

extend(true, DocsManager.prototype, Logging.prototype);

DocsManager.prototype.logging_prefix = 'DocsManager';

It's important to add #logging_prefix, otherwise the methods won't know which class originally had the function implemented.

Usually you use it with just one parameter:

In open source, JavaScript, node.JS & Spludo By DracoBlue @ 22:35 07.10.2010

node.js facebook client for graph and rest api

Today I finished packaging the node-facebook-client. The first version 1.0.0 contains the functions necessary to:

1
2
3
4
5
6
7
8
9
- do signed and unsiged requests
> graph api
> rest api
- generate a session from an
> accesstoken
> code+redirect_uri (oauth 2.0)
> ... or by using a session-key (facebook connect)
- validate a signature from facebook
- sign a request for facebook

An example and the source code can be found at the official github page of
node-facebook-client.

Download node-facebook-client 1.0.0 here at dracoblue.net. It should work with any nodejs version after 0.2.0.

If you want to install by using npm, do:

1
npm install facebook-client

Comments and patches appriciated as usual!

ISO 8601 Date String with Node.JS for AmazonWS

When I tried in javascript to calculate the ISO 8601 Date String, I noticed that there is already such method on the Date object.

This method is called toISOString and is not yet documented at the mdc page.

This date format is needed for instance for the amazon web services.

If you need a implementation anyways (even though toISOString should be available), here is a plain javascript implementation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function toISO8601(date) {
var pad_two = function(n) {
return (n < 10 ? '0' : '') + n;
};

var pad_three = function(n) {
return (n < 100 ? '0' : '') + (n < 10 ? '0' : '') + n;
};

return [
date.getUTCFullYear(),
'-',
pad_two(date.getUTCMonth() + 1),
'-',
pad_two(date.getUTCDate()),
'T',
pad_two(date.getUTCHours()),
':',
pad_two(date.getUTCMinutes()),
':',
pad_two(date.getUTCSeconds()),
'.',
pad_three(date.getUTCMilliseconds()),
'Z',
].join('');
}

It takes a javascript date object and converts it to an iso 8601 date string.

In JavaScript & node.JS By DracoBlue @ 21:28 03.10.2010