cruxx commited on
Commit
8f79e71
·
1 Parent(s): ddae713

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +3 -3
index.js CHANGED
@@ -11,6 +11,7 @@ const cache = new Map()
11
  const app = express()
12
  app.set('json spaces', 4)
13
  app.use(morgan('dev'))
 
14
  app.use(async (_, __, next) => {
15
  for (let [url, data] of cache) {
16
  const timeReset = 10 * 60 * 1000 // 10 min
@@ -21,7 +22,7 @@ app.use(async (_, __, next) => {
21
  }
22
  next()
23
  })
24
-
25
 
26
  app.all('/', (req, res) => {
27
  const obj = {}
@@ -48,7 +49,6 @@ app.get('/api', async (req, res) => {
48
  if (!/https?:\/\//.test(url)) return res.json({ success: false, message: 'Invalid url' })
49
 
50
  const data = cache.has(url) ? cache.get(url) : await ssyoutube(url)
51
- delete data.lastFetch
52
 
53
  data.message ?
54
  res.json({ success: false, message: data.message, result: data }) :
@@ -88,7 +88,7 @@ async function ssyoutube(url) {
88
  res.url().includes('ssyoutube.com/api') && res.request().resourceType() === 'xhr')
89
 
90
  const json = await response.json()
91
- cache.set(url, Object.assign(json, { lastFetch: Date.now() }))
92
  await browser.close()
93
 
94
  return json
 
11
  const app = express()
12
  app.set('json spaces', 4)
13
  app.use(morgan('dev'))
14
+ /*
15
  app.use(async (_, __, next) => {
16
  for (let [url, data] of cache) {
17
  const timeReset = 10 * 60 * 1000 // 10 min
 
22
  }
23
  next()
24
  })
25
+ */
26
 
27
  app.all('/', (req, res) => {
28
  const obj = {}
 
49
  if (!/https?:\/\//.test(url)) return res.json({ success: false, message: 'Invalid url' })
50
 
51
  const data = cache.has(url) ? cache.get(url) : await ssyoutube(url)
 
52
 
53
  data.message ?
54
  res.json({ success: false, message: data.message, result: data }) :
 
88
  res.url().includes('ssyoutube.com/api') && res.request().resourceType() === 'xhr')
89
 
90
  const json = await response.json()
91
+ // cache.set(url, Object.assign(json, { lastFetch: Date.now() }))
92
  await browser.close()
93
 
94
  return json