This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const micro = require('micro'); | |
// taken directly from | |
// https://github.com/zeit/now-builders/blob/f67480a98ac461dc2fe6bb27e8a4ea86e9b6b60a/packages/now-node/src/helpers.ts#L47-L60 | |
function queryParser({ url = '/' }) { | |
const { URL } = require('url'); | |
// we provide a placeholder base url because we only want searchParams | |
const params = new URL(url, 'https://n').searchParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkStatus(response) { | |
if (response.status >= 200 && response.status < 300) { | |
return response; | |
} else { | |
var error = new Error(response.statusText); | |
error.response = response; | |
throw error; | |
} | |
}; |