mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-10-22 14:43:10 +00:00
unified code style
This commit is contained in:
parent
87ed3314bb
commit
d5c0039566
4
app.js
4
app.js
@ -19,7 +19,7 @@ exec('npm info NeteaseCloudMusicApi version', (err, stdout, stderr) => {
|
||||
const app = express()
|
||||
|
||||
// CORS
|
||||
app.use(function(req, res, next){
|
||||
app.use((req, res, next) => {
|
||||
if(req.path !== '/' && !req.path.includes('.')){
|
||||
res.header({
|
||||
'Access-Control-Allow-Credentials': true,
|
||||
@ -33,7 +33,7 @@ app.use(function(req, res, next){
|
||||
})
|
||||
|
||||
// cookie parser
|
||||
app.use(function(req, res, next){
|
||||
app.use((req, res, next) => {
|
||||
req.cookies = {}, (req.headers.cookie || '').split(/\s*;\s*/).forEach(pair => {
|
||||
let crack = pair.indexOf('=')
|
||||
if(crack < 1 || crack == pair.length - 1) return
|
||||
|
@ -4,7 +4,7 @@ const queryString = require('querystring')
|
||||
|
||||
request.debug = true
|
||||
|
||||
function chooseUserAgent(ua){
|
||||
const chooseUserAgent = (ua) => {
|
||||
const userAgentList = [
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||
@ -33,7 +33,7 @@ function chooseUserAgent(ua){
|
||||
return userAgentList[index]
|
||||
}
|
||||
|
||||
function createRequest(method, url, data, options){
|
||||
const createRequest = (method, url, data, options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
let headers = {'User-Agent': chooseUserAgent(options.ua)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user