mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 14:37:21 +01:00
21 lines
514 B
JavaScript
21 lines
514 B
JavaScript
const storeDir = process.env.JSON_STORE || '/tmp/pdfer-store/';
|
|
console.log(`using json-store at ${storeDir}`);
|
|
|
|
const { promisify } = require('util');
|
|
|
|
const store = require('json-fs-store')(storeDir);
|
|
const sortBy = require('lodash.sortby');
|
|
|
|
const list = promisify(store.list);
|
|
const load = promisify(store.load);
|
|
const add = promisify(store.add);
|
|
|
|
module.exports = {
|
|
list: () => list()
|
|
.then(result => sortBy(result, 'created').reverse()),
|
|
load: id => load(id),
|
|
add: item => add(item),
|
|
}
|
|
|
|
|