Skip to content

Commit

Permalink
Bump version, https support
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoliy Chakkaev committed May 17, 2011
1 parent 1ed8523 commit 4035570
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
0.1.3

HTTPS Support
-------------

Just place your key and cert into config directory, railway will use it.
Default names for keys are `tsl.key` and `tsl.cert`, but you can store in in another place, in that case just pass filenames to createServer function:
`server.js`

require('railway').createServer({key: '/tmp/key.pem', cert: '/tmp/cert.pem'});

0.1.2

- npmfile
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,25 @@ On initialization rails-like directories tree generated, like that:
| `-- posts_helper.js
`-- config
|-- database.json
`-- routes.js
|-- routes.js
|-- tsl.cert
`-- tsl.key

HTTPS Support
-------------

Just place your key and cert into config directory, railway will use it.
Default names for keys are `tsl.key` and `tsl.cert`, but you can store in in another place, in that case just pass filenames to createServer function:
`server.js`

require('railway').createServer({key: '/tmp/key.pem', cert: '/tmp/cert.pem'});

Few helpful commands:

# generate private key
openssl genrsa -out config/tsl.key
# generate cert
openssl req -new -x509 -key config/tsl.key -out config/tsl.cert -days 1095 -batch

Routing
-------
Expand Down
8 changes: 5 additions & 3 deletions lib/onrailway.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ exports.init = function (app) {
};
};

exports.createServer = function () {
exports.createServer = function (options) {
options = options || {};

var keys, app,
key = process.cwd() + '/config/tsl.key',
cert = process.cwd() + '/config/tsl.cert';
key = options.key || process.cwd() + '/config/tsl.key',
cert = options.cert || process.cwd() + '/config/tsl.cert';

if (path.existsSync(key) && path.existsSync(cert)) {
keys = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ "name": "railway"
, "version": "0.1.2"
, "version": "0.1.3"
, "author": "Anatoliy Chakkaev"
, "description": "Railway features for Express.js framework"
, "homepage": "http://github.com/1602/express-on-railway"
Expand Down
4 changes: 1 addition & 3 deletions templates/server.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env coffee

app = module.exports = require('express').createServer()

require('express-on-railway').init(app)
app = module.exports = require('railway').createServer()

if not module.parent
app.listen 3000
Expand Down
4 changes: 1 addition & 3 deletions templates/server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env node

var app = module.exports = require('express').createServer();

require('express-on-railway').init(app);
var app = module.exports = require('railway').createServer();

if (!module.parent) {
app.listen(3000);
Expand Down

0 comments on commit 4035570

Please sign in to comment.