Skip to content

Commit

Permalink
mongoose injection
Browse files Browse the repository at this point in the history
  • Loading branch information
Illyism committed Mar 6, 2024
1 parent 510f94c commit db61c46
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sample-apps/next-sample-app/app/mongoose/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Form = () => {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ message }),
body: JSON.stringify({ message: { $gt: "" } }),
});
await res.json();
window.location.reload();
Expand Down
6 changes: 4 additions & 2 deletions sample-apps/next-sample-app/app/mongoose/write/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { runWithContext } from '@aikidosec/guard'

export async function POST(req: NextRequest) {
await connectMongo();
const { message } = await req.json();
const body = await req.json();
await runWithContext(
{
body: { message },
body,
url: req.url,
method: req.method,
query: undefined,
Expand All @@ -23,6 +23,8 @@ export async function POST(req: NextRequest) {
}, {}),
},
async () => {
const { message } = body
const msg = await Guestbook.find({ message }, {}, { sort: { _id: -1 } });
await Guestbook.create({ message });
}
);
Expand Down
4 changes: 2 additions & 2 deletions sample-apps/next-sample-app/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Link from "next/link";
export default function Home() {
return (
<main className="grid grid-cols-4 p-16 items-center justify-center">
<Link href="/mongodb" className="p-4 rounded-md bg-gray-900 hover:bg-gray-800">
MongoDB
<Link href="/mongoose" className="p-4 rounded-md bg-gray-900 hover:bg-gray-800">
mongoose
</Link>
</main>
);
Expand Down

0 comments on commit db61c46

Please sign in to comment.