Move api to v1 folder

This commit is contained in:
2022-06-27 09:08:26 -05:00
parent 6fe79a1892
commit 2fa58305cb
15 changed files with 43 additions and 35 deletions

View File

@@ -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;

View File

@@ -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);
});

View File

@@ -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);
});

View File

@@ -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);
});

View File

@@ -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);
});

View File

@@ -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;

View 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;

View File

@@ -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;

View 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;

View 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
View 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;

View File

@@ -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 />