Say you want to fetch some data at regular intervals into your project and this data is to be fetched from external APIs, use this application to create/schedule cron jobs and save data to ur database (i used mongo here)
classDiagram
class apiSchema {
_id: ObjectId
appId: ObjectId
apiName: String
apiRoute: String
requestType: String
queryParams: Mixed
headerParams: Mixed
payload: Mixed
isActive: Boolean
frequency: String
triggerTime: Date
cronExpression: String
history: Array
createdAt: Date
appName: String
description: String
rootPath: String
}
class applicationSchema {
_id: ObjectId
appName: String
description: String
rootPath: String
apiList: Array
auth: Object
}
apiSchema *-- applicationSchema : appId
- 2 schemas
Application
andAPI
where we store application and api data respectively - Each application contains a list of APIs which are cron jobs to be targetted
- 2 ways to run the jobs, Automatic or Manual. frequency field in APIs help us differentiate this. If
'Instant'
, its manual else the later - If the server restarts, we'll pick up from where we left off by checking the
isActive
status
npm i
npm run dev
: for running locally (nodemon enabled)npm start
for production
- Create a
.env
file at the root and initialize all variables you'll need fromconfig.js
- Example
securityKey: process.env.NODE_APP_SECURITY_KEY
you will make an entry in .env called NODE_APP_SECURITY_KEY: XYZ
- Be nice, create a PR and I'll review them