codehooks-js 1.2.1 → 1.2.2

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.
@@ -16,7 +16,8 @@ let _eventHooks = null;
16
16
 
17
17
 
18
18
  /**
19
- *
19
+ * Crudlify
20
+ * @see {@link https://codehooks.io/docs/database-rest-api}
20
21
  * @param {object} app - Codehooks app ( npm package codehooks-js)
21
22
  * @param {object} schema - Yup schema object
22
23
  * @param {object} options - Options
package/index.js CHANGED
@@ -583,6 +583,15 @@ export const schedule = {
583
583
  "run": async (payload, worker) => {
584
584
  const conn = await datastore.open()
585
585
  return await conn.runAt(new Date(), payload, worker)
586
+ },
587
+ /**
588
+ * Call function on cron expression
589
+ * @param {string} payload
590
+ * @param {function} worker
591
+ * @returns void
592
+ */
593
+ "cron": async (cronExpression, ...hook) => {
594
+ return Codehooks.getInstance().job(cronExpression, ...hook);
586
595
  }
587
596
  }
588
597
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codehooks-js",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "description": "Codehooks.io official library - provides express.JS like syntax",
6
6
  "main": "index.js",
@@ -5,6 +5,9 @@
5
5
  * @property {function(httpResponse):void} json - Pipe datastream to JSON output
6
6
  * @property {function():Promise.<object[]>} toArray - Return an array of objects
7
7
  */
8
+
9
+ import { httpResponse } from "..";
10
+
8
11
  /**
9
12
  *
10
13
  * @param {DataStream} readable - JSON stream
@@ -34,7 +37,7 @@ export type DataStream = {
34
37
  /**
35
38
  * - Pipe datastream to JSON output
36
39
  */
37
- json: (arg0: httpResponse) => void;
40
+ json: (response: httpResponse) => void;
38
41
  /**
39
42
  * - Return an array of objects
40
43
  */
package/types/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export const coderunner: any;
28
28
  export namespace schedule {
29
29
  function runAt(date: any, payload: any, worker: string): Promise<any>;
30
30
  function run(payload: any, worker: string): Promise<any>;
31
+ function cron(cronExpression: string, ...hook: ((request: httpRequest, response: httpResponse, next: (error?: string) => void) => any)[]): void;
31
32
  }
32
33
  /**
33
34
  * Virtual filesystem
@@ -38,11 +39,11 @@ export namespace filestore {
38
39
  * @param path Absolute path til file
39
40
  * @param options Not in use
40
41
  */
41
- function getReadStream(path: string, options?: any): any;
42
- function readFile(path: string, options?: any): any;
43
- function saveFile(path: string, buffer: any, options?: any): any;
44
- function deleteFile(path: string, options?: any): any;
45
- function list(path: string, options?: any): any;
42
+ function getReadStream(path: string, options?: any): Promise<ReadableStream>;
43
+ function readFile(path: string, options?: any): Promise<String>;
44
+ function saveFile(path: string, buffer: any, options?: any): Promise<any>;
45
+ function deleteFile(path: string, options?: any): Promise<any>;
46
+ function list(path: string, options?: any): Promise<Array<Object>>;
46
47
  function readFileAsBuffer(path: any): Promise<any>;
47
48
  }
48
49
  export default _coho;
@@ -326,30 +327,30 @@ export type Filesystem = {
326
327
  /**
327
328
  * - Get binary file input stream. Takes a path (string) to file (e.g. /static/logo.png) and an options object (Object) for future use. Returns a Promise resolving to a binary data stream emitter.
328
329
  */
329
- getReadStream: (arg0: string, arg1: any) => Promise<ReadableStream>;
330
+ getReadStream: (filePath: string, options?: any) => Promise<ReadableStream>;
330
331
  /**
331
332
  * - Get file as text. Takes an absolute path (string) to file (e.g. /static/home.html) and an options object (Object) for future use. Returns a Promise resolving to the file content (string).
332
333
  */
333
- readFile: (arg0: string, arg1: any) => Promise<string>;
334
+ readFile: (filePath: string, options?: any) => Promise<string>;
334
335
  /**
335
336
  * - Save file binary buffer. Takes an absolute path (string) to file (e.g. /static/home.html), a buffer (Buffer) to save, and file meta data (Object). Returns a Promise resolving to the save result.
336
337
  */
337
- saveFile: (arg0: string, arg1: Buffer, arg2: any) => Promise<any>;
338
+ saveFile: (filePath: string, buf: any, options?: any) => Promise<any>;
338
339
  /**
339
340
  * - Delete a file. Takes an absolute path (string) to file and an options object (Object) for future use. Returns a Promise resolving to the result.
340
341
  */
341
- deleteFile: (arg0: string, arg1: any) => Promise<any>;
342
+ deleteFile: (filePath: string, options?: any) => Promise<any>;
342
343
  /**
343
344
  * - List content of a file directory. Takes an absolute path (string) to file and an options object (Object) for future use. Returns a Promise resolving to the result.
344
345
  */
345
- list: (arg0: string, arg1: any) => Promise<any>;
346
+ list: (filePath: string, options?: any) => Promise<any>;
346
347
  /**
347
348
  * - Read file into a Buffer. Takes an absolute path (*) to file. Returns a Promise resolving to a Buffer.
348
349
  */
349
- readFileAsBuffer: (arg0: any) => Promise<Buffer>;
350
+ readFileAsBuffer: (filePath: any) => Promise<any>;
350
351
  };
351
352
  import { agg } from './aggregation/index.mjs';
352
- import { crudlify as crud } from './crudlify/index.mjs';
353
+ import * as crud from './crudlify/index.mjs';
353
354
  /**
354
355
  * keyvalOptions
355
356
  * @typedef {Object} keyvalOptions
@@ -648,6 +649,7 @@ declare class Codehooks {
648
649
  render: (view: string, data: object, cb: any) => Promise<void>;
649
650
  /**
650
651
  * @description Create CRUD REST API for database
652
+ * @see {@link https://codehooks.io/docs/database-rest-api}
651
653
  * @param {object} schema
652
654
  * @param {object} options
653
655
  * @returns Promise - Eventhooks