UNPKG

795 BJavaScriptView Raw
1import superscript from 'superscript';
2import express from 'express';
3import bodyParser from 'body-parser';
4
5const server = express();
6const PORT = process.env.PORT || 5000;
7
8server.use(bodyParser.json());
9
10let bot;
11
12server.get('/superscript', (req, res) => {
13 if (req.query.message) {
14 return bot.reply('user1', req.query.message, (err, reply) => {
15 res.json({
16 message: reply.string,
17 });
18 });
19 }
20 return res.json({ error: 'No message provided.' });
21});
22
23const options = {
24 factSystem: {
25 clean: true,
26 },
27 importFile: './data.json',
28};
29
30superscript.setup(options, (err, botInstance) => {
31 if (err) {
32 console.error(err);
33 }
34 bot = botInstance;
35
36 server.listen(PORT, () => {
37 console.log(`===> 🚀 Server is now running on port ${PORT}`);
38 });
39});