This commit is contained in:
Matt Isenhower 2022-09-01 17:36:28 -07:00
parent 4a03915689
commit 4d02454231
5 changed files with 41 additions and 0 deletions

6
app/cron.mjs Normal file
View File

@ -0,0 +1,6 @@
import { CronJob } from "cron";
import { sendTweets } from "./twitter/index.mjs";
export default function() {
new CronJob('1 16 * * *', sendTweets, null, true);
}

View File

@ -1,9 +1,11 @@
import dotenv from 'dotenv';
import cron from './cron.mjs';
import { sendTweets } from './twitter/index.mjs';
dotenv.config();
const actions = {
cron,
twitter: sendTweets,
}

View File

@ -8,6 +8,7 @@ services:
working_dir: /app
volumes:
- ./:/app
command: npm run cron
nginx:
image: nginx

30
package-lock.json generated
View File

@ -8,6 +8,7 @@
"name": "splatoon3.ink",
"version": "0.0.0",
"dependencies": {
"cron": "^2.1.0",
"dotenv": "^16.0.2",
"ecstatic": "^4.1.4",
"pinia": "^2.0.13",
@ -714,6 +715,14 @@
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"node_modules/cron": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cron/-/cron-2.1.0.tgz",
"integrity": "sha512-Hq7u3P8y7UWYvsZbSKHHJDVG0VO9O7tp2qljxzTScelcTODBfCme8AIhnZsFwmQ9NchZ3hr2uNr+s3DSms7q6w==",
"dependencies": {
"luxon": "^1.23.x"
}
},
"node_modules/cross-fetch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
@ -1978,6 +1987,14 @@
"node": ">=10"
}
},
"node_modules/luxon": {
"version": "1.28.0",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz",
"integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==",
"engines": {
"node": "*"
}
},
"node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
@ -3681,6 +3698,14 @@
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"cron": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cron/-/cron-2.1.0.tgz",
"integrity": "sha512-Hq7u3P8y7UWYvsZbSKHHJDVG0VO9O7tp2qljxzTScelcTODBfCme8AIhnZsFwmQ9NchZ3hr2uNr+s3DSms7q6w==",
"requires": {
"luxon": "^1.23.x"
}
},
"cross-fetch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
@ -4525,6 +4550,11 @@
"yallist": "^4.0.0"
}
},
"luxon": {
"version": "1.28.0",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz",
"integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ=="
},
"magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",

View File

@ -6,9 +6,11 @@
"build": "vite build",
"preview": "vite preview --port 5050",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"cron": "node app/index.mjs cron",
"twitter": "node app/index.mjs twitter"
},
"dependencies": {
"cron": "^2.1.0",
"dotenv": "^16.0.2",
"ecstatic": "^4.1.4",
"pinia": "^2.0.13",