From 84783efd7f00a06a486f5764f03703eb6dc3363b Mon Sep 17 00:00:00 2001 From: codepupper Date: Mon, 11 Nov 2019 22:52:28 +0100 Subject: [PATCH] making my interaction stuff public --- Dashboard/routes/api.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Dashboard/routes/api.js b/Dashboard/routes/api.js index d88bdb2..ed2ccf9 100644 --- a/Dashboard/routes/api.js +++ b/Dashboard/routes/api.js @@ -1,6 +1,7 @@ var express = require('express'); var api = express.Router(); var config = require('../../config'); +var utils = require('../../utils'); api.get('/', (req, res) => { res.status(200).jsonp({ @@ -9,4 +10,19 @@ api.get('/', (req, res) => { }); }); +api.get('/ints/:kind/:user1?/:user2?', (req, res) => { + if (utils.int[req.params.kind] === undefined) return res.status(404).jsonp({ error: `This does not exist` }); + if (!req.params.user1 || !req.params.user2) return res.status(400).jsonp({ error: `I need two users to work` }); + let LineFromUtils = utils.int[req.params.kind][parseInt(Math.random() * utils.int[req.params.kind].length)]; + let Line = LineFromUtils.replace(/0/g, utils.format.bold(req.params.user1)).replace( + /1/g, + utils.format.bold(req.params.user2) + ); + let respo = LineFromUtils.replace(/0/g, req.params.user1).replace(/1/g, req.params.user2); + res.status(200).jsonp({ + Line: respo, + MarkdownLine: Line + }); +}); + module.exports = api;