making my interaction stuff public

This commit is contained in:
codepupper 2019-11-11 22:52:28 +01:00
parent 14dc59b6d3
commit 84783efd7f

View file

@ -1,6 +1,7 @@
var express = require('express'); var express = require('express');
var api = express.Router(); var api = express.Router();
var config = require('../../config'); var config = require('../../config');
var utils = require('../../utils');
api.get('/', (req, res) => { api.get('/', (req, res) => {
res.status(200).jsonp({ 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; module.exports = api;