-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (21 loc) · 1.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const database = require('./src/database');
module.exports = (db, docClient) => {
const instance = new database(db, docClient);
return function(table) {
const safeOp = (command) => instance.safeOp(instance.command(command));
const sanitizeOutputChain = (command) => instance.sanitizeOutput(safeOp(command))(table);
const sanitizeBothChain = (command) => instance.sanitizeOutput(instance.sanitizeInput(safeOp(command)))(table);
const noSanitizeChain = (command) => safeOp(command)(table);
this.getAll = sanitizeOutputChain(instance.getAll);
this.unsafeGetAll = noSanitizeChain(instance.getAll);
this.get = sanitizeOutputChain(instance.get);
this.unsafeGet = noSanitizeChain(instance.get);
this.create = sanitizeOutputChain(instance.create);
this.update = sanitizeBothChain(instance.update);
this.unsafeUpdate = noSanitizeChain(instance.update);
this.delete = noSanitizeChain(instance.remove);
this.query = sanitizeOutputChain(instance.query);
this.unsafeQuery = noSanitizeChain(instance.query);
this.batch = instance.batchWrite;
}
}