Skip to content

Commit 2fc709c

Browse files
committed
feat: add resp do server com tempo agendado
1 parent 9ea72fa commit 2fc709c

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

cron.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var CronJob = require('cron').CronJob;
2+
var express = require('express');
3+
const http = require(`http`);
4+
const app = express();
5+
6+
const job = new CronJob('0 */1 * * * *', function () {
7+
app.get(`/health`, (req, res) => res.status(200).json(`OK`));
8+
const server = http.createServer(app);
9+
server.listen(
10+
1337,
11+
() => console.log(`-- Backend Service (1337) --`)
12+
);
13+
});
14+
console.log('Resposta do servidor a cada minuto');
15+
job.start();

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"author": "",
1111
"license": "ISC",
1212
"dependencies": {
13+
"cron": "^2.3.0",
1314
"express": "^4.16.4"
1415
}
1516
}

0 commit comments

Comments
 (0)