Skip to content

Commit

Permalink
Add cron
Browse files Browse the repository at this point in the history
  • Loading branch information
misenhower committed Sep 2, 2022
1 parent 4a03915 commit 4d02454
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/cron.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CronJob } from "cron";
import { sendTweets } from "./twitter/index.mjs";

export default function() {
new CronJob('1 16 * * *', sendTweets, null, true);
}
2 changes: 2 additions & 0 deletions app/index.mjs
Original file line number Diff line number Diff line change
@@ -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,
}

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
working_dir: /app
volumes:
- ./:/app
command: npm run cron

nginx:
image: nginx
Expand Down
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4d02454

Please sign in to comment.