A hands-on Node.js/Next.js playground with REST and GraphQL APIs. Prisma + SQLite, seed data, and 10 guided challenges covering pagination, auth, caching, DataLoader, file uploads, subscriptions, and testing.
TypeScript Next.js 15 Prisma + GraphQL12 KB โ Next.js 15 + TypeScript + Prisma + GraphQL Yoga + scripts + README + 10 tasks
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users | List all users |
| POST | /api/users | Create user |
| GET/PUT/DELETE | /api/users/:id | Get/update/delete user |
| GET | /api/posts?authorId=X&published=true | List posts with filters |
| POST | /api/posts | Create post |
| GET/PUT/DELETE | /api/posts/:id | Get/update/delete post |
| GET/POST | /api/comments | List/create comments |
| GET/DELETE | /api/comments/:id | Get/delete comment |
Endpoint: POST /api/graphql
Queries: users, user(id), posts, post(id), comments
Mutations: createUser, updateUser, deleteUser, createPost, updatePost, deletePost, createComment, deleteComment
Accept cursor and take params. Return { data, nextCursor }. Add to GraphQL too.
100 requests/minute per IP. Return 429 with Retry-After header. Add X-RateLimit headers.
POST /api/auth/register and /api/auth/login. Protect POST/PUT/DELETE routes. Add me query to GraphQL.
Add Zod schemas to all REST routes and GraphQL mutations. Return structured 400 errors with field details.
Custom error classes: NotFoundError, ValidationError, AuthError. Handle Prisma errors (P2002, P2025).
Add posts field to User type in GraphQL. The N+1 issue appears. Fix with DataLoader batch loading.
In-memory or Redis cache. Cache key includes query params. Invalidate on create/update/delete. Add X-Cache header.
POST /api/users/:id/avatar. Store in public/uploads/. Validate type (JPEG/PNG) and size (max 2MB).
Add postCreated and commentAdded(postId) subscriptions. SSE transport via graphql-yoga.
Test REST CRUD, GraphQL queries/mutations, error cases. Separate test database. At least 5 tests.