REST-EASY-LOKI
A simple REST interface for the in-memory database, lokijs
, featuring:
Installation
npm install
npm start
Usage
To simply run the lokijs
server and expose the CRUD services.
npm run serve
To embed it in your own project, do something like the following:
import { api, db } from 'rest-easy-loki';
export const collectionName = 'documents';
export const startService = (done: () => void) => {
db.startDatabase('my_database_file.json', () => {
api.listen(options.port).on('listening', () => {
const exists = db.collections().reduce((acc, cur) => acc || cur.name === collectionName, false);
if (!exists) {
db.createCollection(collectionName, ['file']);
}
console.info(`Server running on port ${options.port}.`);
done();
});
});
};