anote-server-libs 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,7 +52,7 @@ class MemoryCache {
52
52
  }
53
53
  set(key, val) {
54
54
  if (this.cache)
55
- return new Promise(resolve => this.cache.add(this.localKey + key, JSON.stringify(val), 15 * 60, resolve));
55
+ return new Promise(resolve => this.cache.set(this.localKey + key, JSON.stringify(val), 15 * 60, resolve));
56
56
  else {
57
57
  this.localCache[key] = val;
58
58
  return Promise.resolve();
@@ -49,7 +49,7 @@ export class MemoryCache<T> {
49
49
  }
50
50
 
51
51
  set(key: string | number, val: T): Promise<void> {
52
- if(this.cache) return new Promise(resolve => this.cache.add(this.localKey + key, JSON.stringify(val), 15 * 60, resolve));
52
+ if(this.cache) return new Promise(resolve => this.cache.set(this.localKey + key, JSON.stringify(val), 15 * 60, resolve));
53
53
  else {
54
54
  this.localCache[key] = val;
55
55
  return Promise.resolve();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anote-server-libs",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Helpers for express-TS servers",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -7,12 +7,7 @@ exports.ajv.addKeyword({
7
7
  keyword: 'maxDigits',
8
8
  type: 'number',
9
9
  schemaType: 'number',
10
- code(cxt) {
11
- const { data, schema } = cxt;
12
- const op = (0, ajv_1._) `!==`;
13
- const roundedData = Math.round(data * 10 ** schema) / (10 ** schema);
14
- cxt.fail((0, ajv_1._) `${roundedData} ${op} ${data}`);
15
- }
10
+ validate: (schema, data) => typeof data === 'number' && Math.round(data * 10 ** schema) / (10 ** schema) === data
16
11
  });
17
12
  function WithBody(schema) {
18
13
  if (schema.type === 'object') {
@@ -6,12 +6,7 @@ ajv.addKeyword({
6
6
  keyword: 'maxDigits',
7
7
  type: 'number',
8
8
  schemaType: 'number',
9
- code(cxt: any) {
10
- const {data, schema} = cxt;
11
- const op = _`!==`;
12
- const roundedData = Math.round(data * 10 ** schema) / (10 ** schema);
13
- cxt.fail(_`${roundedData} ${op} ${data}`);
14
- }
9
+ validate: (schema: number, data: any) => typeof data === 'number' && Math.round(data * 10 ** schema) / (10 ** schema) === data
15
10
  });
16
11
 
17
12
  export function WithBody(schema: any) {