Skip to content

Yhanli/nodejs-functions

Repository files navigation


nodejs functions a simple nodejs function allow for schedule tasks
Perfect for simple schedule tasks

Functions for Node.js

Version Monthly Downloads

🌟 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

Both file will later build to the dist folder which then give the path

  1. ./dist/example/example.js
  2. ./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 instead

Future Features

  • Queue trigger
  • DB trigger
  • Storage trigger
  • HTTP/HTTPS

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published