diff --git a/README.md b/README.md index dec6c21..b91f61b 100644 --- a/README.md +++ b/README.md @@ -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"}} + ``` diff --git a/sop-app/app/api/test/route.ts b/sop-app/app/api/test/route.ts new file mode 100644 index 0000000..cbc6273 --- /dev/null +++ b/sop-app/app/api/test/route.ts @@ -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 } + ); + } +}