Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
"# workhelper"
# workhelper

## API sanity check

1. Install dependencies and start the development server from the Next.js app directory:
```bash
cd sop-app
npm install
npm run dev
```
2. With the server running on [http://localhost:3000](http://localhost:3000), hit the health-check endpoint:
```bash
curl http://localhost:3000/api/test
# {"status":"ok"}
```
3. To verify request parsing via POST, send JSON data:
```bash
curl -X POST http://localhost:3000/api/test \
-H "Content-Type: application/json" \
-d '{"message":"hello"}'
# {"status":"ok","received":{"message":"hello"}}
```
17 changes: 17 additions & 0 deletions sop-app/app/api/test/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NextResponse } from "next/server";

export function GET() {
return NextResponse.json({ status: "ok" }, { status: 200 });
}

export async function POST(request: Request) {
try {
const data = await request.json();
return NextResponse.json({ status: "ok", received: data }, { status: 200 });
} catch (error) {
return NextResponse.json(
{ status: "error", message: "Invalid JSON body" },
{ status: 400 }
);
}
}