forked from kubowania/wordle-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (43 loc) · 1.35 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
46
47
48
49
50
const PORT = 8000
const axios = require("axios").default
const express = require("express")
const cors = require("cors")
require('dotenv').config()
const app = express()
app.use(cors())
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) => {
const word = req.query.word
const options = {
method: 'GET',
url: 'https://twinword-word-graph-dictionary.p.rapidapi.com/association/',
params: {entry: word},
headers: {
'x-rapidapi-host': 'twinword-word-graph-dictionary.p.rapidapi.com',
'x-rapidapi-key': process.env.RAPID_API_KEY
}
}
axios.request(options).then((response) => {
console.log(response.data)
res.json(response.data.result_msg)
}).catch((error) => {
console.error(error)
})
})
app.listen(PORT, () => console.log('Server running on port ' + PORT))