mirror of
https://github.com/topjohnwu/magiskbot.git
synced 2024-11-23 03:49:45 +00:00
Deploy to Heroku
This commit is contained in:
parent
54eda6db0f
commit
6779ff5173
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
node_modules
|
||||
package-lock.json
|
||||
dist
|
||||
env.sh
|
||||
.env
|
@ -2,7 +2,8 @@ import Github from './Github';
|
||||
|
||||
if (process.env.MAGISK_SERVER_USERNAME === undefined ||
|
||||
process.env.MAGISK_SERVER_TOKEN === undefined ||
|
||||
process.env.MAGISK_SERVER_PORT === undefined) {
|
||||
process.env.MAGISK_SERVER_DOMAIN === undefined ||
|
||||
process.env.PORT === undefined) {
|
||||
throw 'Error: Please setup environment variables'
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,10 @@ import { submissions, magiskRepo, ID_SET } from './Shared';
|
||||
magiskRepo.getRepos().then(res => res.data).then(repos => {
|
||||
// Add all repos to the set
|
||||
repos.forEach(repo => ID_SET.add(repo.description));
|
||||
repos.forEach(RepoModerator);
|
||||
submissions.listIssues().then(res => res.data.forEach(SubmissionHandler));
|
||||
// Start the server to monitor webhooks
|
||||
server.listen(process.env.MAGISK_SERVER_PORT,
|
||||
() => console.log(`Server listening to ${process.env.MAGISK_SERVER_PORT}`));
|
||||
// Start the server
|
||||
server.listen(process.env.PORT, () => console.log(`Server listening to ${process.env.PORT}`));
|
||||
})
|
||||
|
||||
// Run full scan every hour
|
||||
setInterval(() => magiskRepo.getRepos().then(res => res.data.forEach(RepoModerator)), 60 * 60 * 1000);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import express from 'express';
|
||||
import bodyParser from 'body-parser';
|
||||
import axios from 'axios';
|
||||
|
||||
import SubmissionHandler from './SubmissionHandler';
|
||||
import RepoModerator from './RepoModerator';
|
||||
@ -21,7 +22,11 @@ server.post('/moderate', (req, res) => {
|
||||
RepoModerator(req.body.repository);
|
||||
}
|
||||
res.send();
|
||||
})
|
||||
});
|
||||
|
||||
server.get('/ping', (req, res) => res.send('PING!'));
|
||||
|
||||
// Wake Heroku every 15 mins
|
||||
setInterval(() => axios.get(`${process.env.MAGISK_SERVER_DOMAIN}/ping`).then(res => console.log(res.data)), 15 * 60 * 1000);
|
||||
|
||||
export default server;
|
||||
|
||||
|
@ -3,11 +3,16 @@
|
||||
"version": "1.0.0",
|
||||
"description": "Auto handle new module requests",
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
"node": "8.10.x",
|
||||
"npm": "6.1.x"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "babel-node lib/index.js",
|
||||
"nodemon": "nodemon lib/index.js --exec babel-node",
|
||||
"build": "babel lib -d dist",
|
||||
"build": "rm -rf dist && babel lib -d dist",
|
||||
"prod": "node dist/index.js",
|
||||
"heroku-postbuild": "npm run build",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "topjohnwu",
|
||||
|
Loading…
Reference in New Issue
Block a user