Move api to v1 folder
This commit is contained in:
@@ -25,7 +25,7 @@ export async function getServerSideProps({ req, res }) {
|
||||
|
||||
if (!session || !session.user) {
|
||||
res.writeHead(302, {
|
||||
Location: "/api/login",
|
||||
Location: "/api/v1/login",
|
||||
});
|
||||
res.end();
|
||||
return;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import auth0 from "../../lib/auth0";
|
||||
import { withErrorHandling } from "../../lib/apiHelpers";
|
||||
|
||||
export default callback = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleCallback(req, res);
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
import auth0 from "../../lib/auth0";
|
||||
import { withErrorHandling } from "../../lib/apiHelpers";
|
||||
|
||||
export default login = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleLogin(req, res);
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
import auth0 from "../../lib/auth0";
|
||||
import { withErrorHandling } from "../../lib/apiHelpers";
|
||||
|
||||
export default logout = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleLogout(req, res);
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
import auth0 from "../../lib/auth0";
|
||||
import { withErrorHandling } from "../../lib/apiHelpers";
|
||||
|
||||
export default me = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleProfile(req, res);
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import db from "../../lib/db";
|
||||
import db from "../../../lib/db";
|
||||
import Ajv from "ajv";
|
||||
import addFormats from "ajv-formats";
|
||||
import { withErrorHandling } from "../../lib/apiHelpers";
|
||||
import { withErrorHandling } from "../../../lib/apiHelpers";
|
||||
|
||||
const handler = withErrorHandling(async (req, res) => {
|
||||
const { method } = req;
|
||||
8
web/pages/api/v1/callback.js
Normal file
8
web/pages/api/v1/callback.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import auth0 from "../../../lib/auth0";
|
||||
import { withErrorHandling } from "../../../lib/apiHelpers";
|
||||
|
||||
const callback = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleCallback(req, res);
|
||||
});
|
||||
|
||||
export default callback;
|
||||
@@ -1,5 +1,5 @@
|
||||
import db from "../../lib/db";
|
||||
import { withErrorHandling } from "../../lib/apiHelpers";
|
||||
import db from "../../../lib/db";
|
||||
import { withErrorHandling } from "../../../lib/apiHelpers";
|
||||
|
||||
const handler = withErrorHandling(async (req, res) => {
|
||||
const { method } = req;
|
||||
8
web/pages/api/v1/login.js
Normal file
8
web/pages/api/v1/login.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import auth0 from "../../../lib/auth0";
|
||||
import { withErrorHandling } from "../../../lib/apiHelpers";
|
||||
|
||||
const login = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleLogin(req, res);
|
||||
});
|
||||
|
||||
export default login;
|
||||
8
web/pages/api/v1/logout.js
Normal file
8
web/pages/api/v1/logout.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import auth0 from "../../../lib/auth0";
|
||||
import { withErrorHandling } from "../../../lib/apiHelpers";
|
||||
|
||||
const logout = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleLogout(req, res);
|
||||
});
|
||||
|
||||
export default logout;
|
||||
8
web/pages/api/v1/me.js
Normal file
8
web/pages/api/v1/me.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import auth0 from "../../../lib/auth0";
|
||||
import { withErrorHandling } from "../../../lib/apiHelpers";
|
||||
|
||||
const me = withErrorHandling(async (req, res) => {
|
||||
await auth0.handleProfile(req, res);
|
||||
});
|
||||
|
||||
export default me;
|
||||
@@ -20,7 +20,7 @@ function Home() {
|
||||
<i>Profile</i> and <i>Logout</i>
|
||||
</p>
|
||||
<p>
|
||||
<form method="POST" action="/api/bookmarks">
|
||||
<form method="POST" action="/api/v1/bookmarks">
|
||||
<label for="title">title: </label>
|
||||
<input type="text" name="title"/>
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user