scnario commited on
Commit
f1b5255
·
verified ·
1 Parent(s): c4b7c29

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +13 -0
server.js CHANGED
@@ -10,6 +10,19 @@ const stringify = (value) => {
10
  return JSON.stringify(value, null, 2)
11
  }
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  app.all('/play', async(req, res) => {
14
  try {
15
  const { q } = req.query || req.body
 
10
  return JSON.stringify(value, null, 2)
11
  }
12
 
13
+ app.all('/search', async(req, res) => {
14
+ try {
15
+ const { q, type = "track", limit = 10 } = req.query || req.body
16
+ if(!q) return res.json({ status: false, error: '"q" parameter is undefined!'})
17
+
18
+ const search = await Spotify.search(q, type, limit)
19
+ //if(!Array.isArray(search)) return res.json({ status: false, error: 'Result is not array.'})
20
+ res.json(search);
21
+ } catch(e) {
22
+ res.json({ status: false, error: e || e.message })
23
+ }
24
+ })
25
+
26
  app.all('/play', async(req, res) => {
27
  try {
28
  const { q } = req.query || req.body