Skip to content

Commit 6409a51

Browse files
committed
Add keepalive task
1 parent 5431d09 commit 6409a51

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ENTRY_POINT=https://shib-test.bu.edu/idp/profile/SAML2/Redirect/SSO
22
CALLBACK_URL=https://app.bostonhacks.io/login/callback
3+
KEEPALIVE_URL=https://app.bostonhacks.io/keepalive
34
ISSUER=https://app.bostonhacks.io/shibboleth
45
SESSION_SECRET=secret
56

app.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const fs = require("fs");
2+
const cron = require("node-cron");
3+
const fetch = require("node-fetch");
24
const admin = require("firebase-admin");
35
const { v4: uuidv4 } = require("uuid");
46
const express = require("express");
@@ -181,3 +183,10 @@ app.use(function(err, req, res, next) {
181183

182184
const serverPort = process.env.PORT || 3030;
183185
app.listen(serverPort, () => console.log(`Listening on port ${serverPort}`));
186+
187+
console.log(`Starting keepalive for ${process.env.KEEPALIVE_URL}`);
188+
cron.schedule("0 */25 * * * *", () =>
189+
fetch(process.env.KEEPALIVE_URL)
190+
.then(res => console.log(`response-ok: ${res.ok}, status: ${res.status}`))
191+
.catch(console.error)
192+
);

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"express-session": "^1.17.0",
1111
"firebase-admin": "^9.0.0",
1212
"firestore-store": "^2.0.1",
13+
"node-cron": "^2.0.3",
14+
"node-fetch": "^2.6.0",
1315
"passport": "^0.4.1",
1416
"passport-saml": "^1.3.3",
1517
"uuid": "^8.2.0"

yarn.lock

+18
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,14 @@ negotiator@0.6.2:
14621462
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
14631463
integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==
14641464

1465+
node-cron@^2.0.3:
1466+
version "2.0.3"
1467+
resolved "https://registry.yarnpkg.com/node-cron/-/node-cron-2.0.3.tgz#b9649784d0d6c00758410eef22fa54a10e3f602d"
1468+
integrity sha512-eJI+QitXlwcgiZwNNSRbqsjeZMp5shyajMR81RZCqeW0ZDEj4zU9tpd4nTh/1JsBiKbF8d08FCewiipDmVIYjg==
1469+
dependencies:
1470+
opencollective-postinstall "^2.0.0"
1471+
tz-offset "0.0.1"
1472+
14651473
node-fetch@^2.2.0, node-fetch@^2.3.0, node-fetch@^2.6.0:
14661474
version "2.6.0"
14671475
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
@@ -1503,6 +1511,11 @@ onetime@^5.1.0:
15031511
dependencies:
15041512
mimic-fn "^2.1.0"
15051513

1514+
opencollective-postinstall@^2.0.0:
1515+
version "2.0.3"
1516+
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259"
1517+
integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==
1518+
15061519
optionator@^0.9.1:
15071520
version "0.9.1"
15081521
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499"
@@ -2016,6 +2029,11 @@ typedarray@^0.0.6:
20162029
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
20172030
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
20182031

2032+
tz-offset@0.0.1:
2033+
version "0.0.1"
2034+
resolved "https://registry.yarnpkg.com/tz-offset/-/tz-offset-0.0.1.tgz#fef920257024d3583ed9072a767721a18bdb8a76"
2035+
integrity sha512-kMBmblijHJXyOpKzgDhKx9INYU4u4E1RPMB0HqmKSgWG8vEcf3exEfLh4FFfzd3xdQOw9EuIy/cP0akY6rHopQ==
2036+
20192037
uid-safe@~2.1.5:
20202038
version "2.1.5"
20212039
resolved "https://registry.yarnpkg.com/uid-safe/-/uid-safe-2.1.5.tgz#2b3d5c7240e8fc2e58f8aa269e5ee49c0857bd3a"

0 commit comments

Comments
 (0)