first working state

This commit is contained in:
jane 2022-04-23 22:58:54 -04:00
parent 0a9b76f9c7
commit 4a0db151d4
23 changed files with 512 additions and 74 deletions

View file

@ -12,6 +12,20 @@ export default NextAuth({
}),
],
callbacks: {
async signIn({ user, account, profile, email, credentials }) {
console.log(user, account, profile, email, credentials);
if (user.image != profile.image_url) {
await prisma.user.update({
data: {
image: profile.image_url,
},
where: {
id: user.id,
},
});
}
return true;
},
async session({ session, token, user }) {
session.user.id = user.id;
// console.log(JSON.stringify(user));

View file

@ -1,7 +1,9 @@
import { getAllBorders } from "../../../lib/borders";
import { getAllBorders, countAllBorders } from "../../../lib/borders";
export default function handler(req, res) {
getAllBorders().then((result) => {
return res.status(200).json(result);
getAllBorders(req.query?.limit, req.query?.cursor).then((result) => {
countAllBorders().then((count) => {
return res.status(200).json({ data: result, count });
});
});
}

View file

@ -1,5 +1,7 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default function handler(req, res) {
res.status(200).json({ name: 'John Doe' })
res.status(200).json({
ok: "ok",
});
}

View file

@ -1,11 +1,21 @@
import { getUserBorders } from "../../../../lib/borders";
import { getUserBorders, setUserBorder } from "../../../../lib/borders";
export default function handler(req, res) {
getUserBorders(req).then((result) => {
if (result) {
return res.status(200).json(result);
} else {
return res.status(404).json({ error: "Not Found" });
}
});
if (req.method === "POST") {
setUserBorder(req, req.body).then((result) => {
if (result) {
return res.status(200).json(result);
} else {
return res.status(500).json({ error: "could not update border" });
}
});
} else {
getUserBorders(req).then((result) => {
if (result) {
return res.status(200).json(result);
} else {
return res.status(404).json({ error: "Not Found" });
}
});
}
}