0.0.6 • Published 1 year ago
nodejs-functions v0.0.6
Functions for Node.js
🌟 Features
- execute a function whenever your scheduled job triggers
🚀 Installation
npm install nodejs-functions🛠 Basic Usage
import { app } from 'nodejs-functions';
app.ScheduledTask('ScheduledFunction1', '* * * * * *', () => {
console.log(`send 1 ${new Date().toISOString()}`);
});or
import { app } from 'nodejs-functions';
function send2() {
console.log(`send 2 ${new Date().toISOString()}`);
}
app.ScheduledTask('ScheduledFunction2', '* * * * * *', send2);Configure Function Directories using .nfunc.json
{
"directory": ["dist/test"],
"ScheduledFunction1_DISABLE": true
}How it run the function
- checkout .nfunc.json, example.ts and example_2.ts
Both file will later build to the dist folder which then give the path
- ./dist/example/example.js
- ./dist/example/example_2.js
Use the .nfunc.json to set the directory to dist/example folder and it will load every function inside individually.
The command below can be use to execute the functions
npx nfunc --config .nfunc.json
# recommended to have it in package.json script insteadFuture Features
- Queue trigger
- DB trigger
- Storage trigger
- HTTP/HTTPS