add route for checking next void time

This commit is contained in:
HF 2022-06-30 15:06:36 +02:00
parent 523b2c32de
commit b9cb6afc0b
4 changed files with 28 additions and 7 deletions

View File

@ -366,4 +366,6 @@ class RpgEvent {
}
}
export default RpgEvent;
const rpgEvent = new RpgEvent();
export default rpgEvent;

View File

@ -7,6 +7,7 @@ import etag from 'etag';
import path from 'path';
import ranking from './ranking';
import voidl from './void';
import history from './history';
import tiles from './tiles';
import chunks from './chunks';
@ -25,6 +26,11 @@ import { GUILDED_INVITE } from '../core/config';
const router = express.Router();
/*
* void info
*/
router.get('/void', voidl);
/*
* ranking of pixels placed
* daily and total

18
src/routes/void.js Normal file
View File

@ -0,0 +1,18 @@
/*
* send information about next void
*/
import rpgEvent from '../core/RpgEvent';
export default (req, res) => {
res.set({
'Cache-Control': `public, max-age=${5 * 60}`,
});
if (rpgEvent.eventTimestamp) {
const time = new Date(rpgEvent.eventTimestamp);
res.send(`Next void at ${time.toUTCString()}`);
} else {
res.send('No void');
}
};

View File

@ -15,7 +15,7 @@ import sequelize from './data/sql/sequelize';
import { connect as connectRedis } from './data/redis/client';
import routes from './routes';
import chatProvider from './core/ChatProvider';
import RpgEvent from './core/RpgEvent';
import rpgEvent from './core/RpgEvent';
import canvasCleaner from './core/CanvasCleaner';
import SocketServer from './socket/SocketServer';
@ -76,11 +76,6 @@ app.use(compression({
app.use(routes);
/*
/* Hourly Event
*/
const rpgEvent = new RpgEvent();
//
// ip config
// -----------------------------------------------------------------------------