simple to use nedb cache layer with restful api routing
restify-nedb (for nedb)
restify-nedb was built to give you restful api resources for client side application frameworks like
knockout.js as well as give you a simple file/memory based cache utilizing nedb. (ps, i love nedb, you should too.) If you haven't already checked it out, maybe you want to use it separate of all of this extra stuff, do it. It's like sqlite, with a subset of mongodb's api. Really neat.
- Let me know if you have any issues, please open issues/prs etc, it's a lot more fun that way
- There's still a good chunk of the
nedbapi I need to wrap in, if you need the core crud stuff, this should work well for you
- I'd like to point out there coule be a few rough parts, but it's coming along.
- Super fast
nedbfile/memory backed cache w/ simple garbage collection
- 100% coffeescript, hate it or love it
- restful routing:
npm install restify-nedb --save
Step 2) Configure your app, needs access to
app, so you can do that a number of ways,
/* example in .js */var express = require'express';var app = express;var restify = require'restify-nedb'mount;var config = require'restify-nedb'config;varconsole.log'here\'s a sample middleware...';return next;;// default config optionsvar opts =filePath: __dirname + '/db/filestore.db'maxAge: 1000 * 60 * 60prefix: '/session'middleware: sampleMiddleware;// initialize our config objectcfg = opts;// if you aren't already using an nedb// instance, then calling this will create// one for you.cfgmakeDataStore;// builds routesapi = cfg app;
express = require "express"app = module.exports = expressrestify = require"restify-nedb"mountconfig = require"restify-nedb"config=consolelog "here's a sample middleware..."nextopts =filePath: confapppathscachemaxAge: 1000 * 60 * 60prefix: "/session"middleware: sampleMiddlewarecfg = opts# if you aren't already using an nedb# instance, then calling this will create# one for you.cfgmakeDataStore# builds routesapi = cfgapp
Step 3) Submit bugs and nasties here.
|ds||DataStore||allow for outside nedb processes to be restified. tip: |
|prefix||String||defines the first route path, for instance |
|version||String||not preferred, as a rule i feel these aren't the best idea for your api, last thing you want is fragmentation in your api|
|exclude||Array||excludes keys/values from the api, good for things like |
|middleware||Array||middlewares, ie passport authentication, logging, analytics|
|memoryStore||Boolean||whether or not keep an in-memory store or a file based persistant store, defaults to |
|fileName||String||file name for your nedb filestore|
|filePath||String||bit easier to change the path and view the contents instead of digging through |
|maxAge||Number||if set to |
- append defaults to false. Set to true to do something similar to
_stalein your body/json will act as an override to
stale, say you need some things to last longer/shorter than other cached items
mocha test\crud.coffee -R spec --compilers coffee:coffee-script
- I would recommend using something like Advanced REST Client for testing, it'll help.
- If you want upto date / latest documentation run
cake docs, this way if I forget, you can easily skim thru the source --
/docsshould be included.
The MIT License (MIT)Copyright (c) 2013 David HigginbothamPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.