This is an express router which allows you to store your static files in a CouchDb database instead of in the file system. This is useful when your website has a mixture of static and dynamic content. It means the entire website is contained within the database and can easily be replicated for redundancy, scaling and offline use.
Tools are included to enable you to develop locally in the file system and then upload to the database.
Alpha testing. This is still very much a "work-in-progress". Fell free to try it and make suggestions but do not use it in production just yet.
npm install express-couchdb-router
Once installed run the ECR utility, ecr init
, to initialise your workspace.
This has the Express based web app. The sample provided allows you to choose whether to run from the local static files (command line option -s or --static) or the database (command line option -d or -database).
node ./app.js -s
will use the static files.
node ./app.js -d
will use the database.
This is the folder where you will develop the static files used by your website. This would not normally be copied to the production server.
The following scripts are added to the package.json:
npm run <script name>
. The configuration file, ecr-config.json, is created as part of the init process. This should be amended as needed by your particular app. The default values will get you started
{
"localDb": { <--- Defines the local database used for testing and staging.
"URL": "http://localhost:5984/<your app name>",
"adminName": (optional) <--- The name of the admin user
"adminPassword": (optional) <--- The password of the admin user
},
"prodDb": { <--- Defines the production database. Not used at the moment.
"Url": (optional),
"admin": (optional),
"password": (optional)
},
"staticFolder": "./static" <--- The local folder where the static files are stored.
}
The database server is initialised as the localhost with the application name (as defined in package.json) for the database name.
The local database can be synchronised to the local static files using the command:
ecr upload
This will copy all the static files into the local database and remove any entries in the database which no longer have matching entries in the static files folder.
This allows for a staging test running from a local database before replicating the local database to the producion database.
Pull requests accepted
Mike Robertson mike@soligeo.scot
Version | Tag | Published |
---|---|---|
0.2.3 | latest | 4yrs ago |