Create server.js
Browse files
server.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const express = require('express');
|
| 2 |
+
const axios = require('axios');
|
| 3 |
+
const spot = require('./lib/spotify.js');
|
| 4 |
+
|
| 5 |
+
const app = express()
|
| 6 |
+
const PORT = 7860
|
| 7 |
+
|
| 8 |
+
const stringify = (value) => {
|
| 9 |
+
return JSON.stringify(value)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
app.all('/play', async(req, res) => {
|
| 13 |
+
const { q } = req.query || req.body
|
| 14 |
+
if(!q) return res.json(stringify({ status: false, error: '"q" parameter is undefined!'}))
|
| 15 |
+
|
| 16 |
+
const spotify = new spot()
|
| 17 |
+
const search = await spotify.search(q, 1)
|
| 18 |
+
console.log(stringify(search))
|
| 19 |
+
})
|