Skip to content

Commit

Permalink
(#36) - specify directory for database files
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed May 28, 2014
1 parent 0f0e32c commit f31ad3c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $ npm install -g pouchdb-server
Options:
-p, --port Port on which to run the server.
-d, --dir Where to store database files (defaults to current directory)
-l, --log Connect log format.
-h, --help Show this usage information.
-u, --user Set Basic Auth username. (Both user and pass required for Basic Auth).
Expand Down
8 changes: 7 additions & 1 deletion bin/pouchdb-server
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

var express = require('express')
, corser = require('corser')
, path = require('path')
, argv = require('optimist').argv
, port = +(argv.p || argv.port || 5984)
, logger = argv.l || argv.log || 'dev'
, user = argv.u || argv.user
, pass = argv.s || argv.pass
, dbpath = argv.d || argv.dir || argv.directory || ''
, useAuth = user && pass
, app = express()
, corserRequestListener = corser.create({
Expand Down Expand Up @@ -61,7 +63,11 @@ if (useAuth) {
});
}

app.use(require('express-pouchdb'));
var expressPouchDB = require('express-pouchdb');
if (dbpath) {
expressPouchDB.setPath(dbpath);
}
app.use(expressPouchDB);
app.listen(port, function () {
console.log('\npouchdb-server listening on port ' + port + '.');
console.log('navigate to http://localhost:' + port + '/_utils for the Fauxton UI.\n');
Expand Down
5 changes: 3 additions & 2 deletions bin/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Usage: pouchdb-server [options]

Options:
-p, --port Port on which to run the server.
-l, --log Connect log format.
-p, --port Port on which to run the server (defaults to 5984)
-d, --dir Where to store database files (defaults to current directory)
-l, --log Connect log format (dev|short|tiny|default)
-h, --help Show this usage information.
-u, --user Set Basic Auth username. (Both user and pass required for Basic Auth).
-s, --pass Set Basic Auth password. (Both user and pass required for Basic Auth).
Expand Down

0 comments on commit f31ad3c

Please sign in to comment.