test: add axios to router
This commit is contained in:
@@ -1,19 +1,29 @@
|
||||
import { default as gist } from './core-app/api/gist.js'
|
||||
import { default as pin } from './core-app/api/pin.js'
|
||||
import { default as gist } from "./core-app/api/gist.js";
|
||||
import { default as pin } from "./core-app/api/pin.js";
|
||||
import axios from "axios";
|
||||
|
||||
export default async (req, res) => {
|
||||
const url = new URL(req.url, 'https://localhost')
|
||||
req.query = Object.fromEntries(url.searchParams.entries())
|
||||
switch(url.pathname) {
|
||||
case '/gist':
|
||||
gist(req, res)
|
||||
break
|
||||
case '/pin':
|
||||
pin(req, res)
|
||||
break
|
||||
default:
|
||||
res.statusCode = 404
|
||||
res.end('Not Found')
|
||||
break
|
||||
}
|
||||
}
|
||||
const url = new URL(req.url, "https://localhost");
|
||||
req.query = Object.fromEntries(url.searchParams.entries());
|
||||
switch (url.pathname) {
|
||||
case "/gist":
|
||||
gist(req, res);
|
||||
break;
|
||||
case "/pin":
|
||||
pin(req, res);
|
||||
break;
|
||||
default:
|
||||
res.statusCode = 404;
|
||||
res.end("Not Found");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
export const dummyRequest = (data, headers) => {
|
||||
return axios({
|
||||
url: "https://api.github.com/graphql",
|
||||
method: "post",
|
||||
headers,
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user