-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: cronjob trigger via env var, refactor
- Loading branch information
1 parent
bb9b045
commit 56894ac
Showing
11 changed files
with
66 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import cron from "node-cron"; | ||
import { createLogger } from "../../util/logger"; | ||
import { spotifyService } from "../spotify/spotifyService"; | ||
import { githubService } from "../github/githubService"; | ||
import { config } from "../../config"; | ||
|
||
const logger = createLogger("Cronjob Service"); | ||
|
||
export async function cronjobService() { | ||
cron.schedule(config.cronExpression, async function () { | ||
logger.info("Cronjob starting github Service"); | ||
await githubService([ | ||
{ endpoint: "issues/comments", owner: "nodejs", repo: "nodejs.dev", key: "comments", dateTime: true }, | ||
{ endpoint: "releases", owner: "nodejs", repo: "postject", key: "releases", dateTime: false }, | ||
{ endpoint: "stargazers", owner: "nodejs", repo: "postject", key: "stars", dateTime: false }, | ||
]); | ||
|
||
logger.info("Cronjob starting spotify Service"); | ||
await spotifyService([ | ||
{ | ||
url: "https://api.spotify.com/v1/browse/categories/0JQ5DAqbMKFEC4WFtoNRpw/playlists", | ||
key: "categoryPlaylists", | ||
}, | ||
{ url: "https://api.spotify.com/v1/playlists/3Na18bFHq9tQOpcBx8dYET/tracks", key: "playlistItems" }, | ||
{ url: "https://api.spotify.com/v1/users/user_id/playlists", key: "userPlaylists" }, | ||
]); | ||
logger.info("Cronjob completed"); | ||
}); | ||
} |
4 changes: 2 additions & 2 deletions
4
src/github/githubController.ts → src/services/github/githubController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/spotify/spotifyController.ts → src/services/spotify/spotifyController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters