fast72 commited on
Commit
2598acb
·
verified ·
1 Parent(s): d2c5621

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +20 -22
server.js CHANGED
@@ -1,29 +1,27 @@
1
  const express = require('express');
2
- const axios = require('axios')
3
- const cheerio = require('cheerio')
4
 
5
- const app = express()
6
- app.set('json spaces', 4)
7
 
8
  const bypass = async (url) => {
9
- axios.get(url)
10
- .then(res => {
11
- const $ = cheerio.load(res.data)
12
- const data = JSON.parse($('#app').attr('data-page'))
13
- const hasil = data.props.link.finish.map(item => ({
14
- name: item.name,
15
- url: item.url
16
- }))
17
- return hasil
18
- })
19
- }
20
 
21
  app.get('/b', async (req, res) => {
22
- const { url } = req.query
23
- const regex = /https:\/\/link2unlock\.com\/[a-zA-Z0-9]+/g
24
- if(!regex.test(url)) return res.json({ success: false, error: 'invalid link'})
25
- const result = await bypass(url)
26
- res.json(result)
27
- })
 
28
 
29
- app.listen(7860)
 
1
  const express = require('express');
2
+ const axios = require('axios');
3
+ const cheerio = require('cheerio');
4
 
5
+ const app = express();
6
+ app.set('json spaces', 4);
7
 
8
  const bypass = async (url) => {
9
+ const res = await axios.get(url);
10
+ const $ = cheerio.load(res.data);
11
+ const data = JSON.parse($('#app').attr('data-page'));
12
+ return data.props.link.finish.map(item => ({
13
+ name: item.name,
14
+ url: item.url
15
+ }));
16
+ };
 
 
 
17
 
18
  app.get('/b', async (req, res) => {
19
+ const { url } = req.query;
20
+ if (!/https:\/\/link2unlock\.com\/[a-zA-Z0-9]+/g.test(url)) {
21
+ return res.json({ success: false, error: 'invalid link' });
22
+ }
23
+ const result = await bypass(url);
24
+ res.json(result);
25
+ });
26
 
27
+ app.listen(7860);