-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (37 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const PORT = 8000;
const axios = require("axios").default;
const express = require("express");
const corrs=require("cors")
var checkWord = require('check-if-word'),
wordChecker = checkWord('en');
require('dotenv').config();
const app = express();
app.use(corrs());
app.get('/word', (req, res) => {
const options = {
method: 'GET',
url: 'https://random-words5.p.rapidapi.com/getMultipleRandom',
params: {count: '5', wordLength: '5'},
headers: {
'X-rapidapi-host': 'random-words5.p.rapidapi.com',
'X-rapidapi-key': process.env.RAPID_API_KEY
}
}
axios.request(options).then((response) => {
console.log(response.data);
res.json(response.data[0]);
}).catch((error) => {
console.error(error);
});
});
app.get('/check', (req, res) => {
console.log(req);
if(wordChecker.check(word))
{
res.json(1);
}
else{
res.json(0);
}
})
app.listen(PORT, () => console.log('Server running on port ' + PORT));