-
Clone the repository:
git clone https://github.com/yourusername/api-testing-lab.git cd api-testing-lab -
Install dependencies:
npm install
-
Environment setup:
- Create a
.envfile in the project root with the following variables:DATABASE_URL="postgresql://username:password@localhost:5432/apitest?schema=public" SUPABASE_URL="your-supabase-url" SUPABASE_KEY="your-supabase-key" PORT=3000 - For testing, create a
.env.testfile with similar variables pointing to a test database
- Create a
-
Database setup:
npx prisma migrate dev
Start the development server:
npm run devThe API will be accessible at http://localhost:3000.
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPOST /api/users- Create userPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/posts- Get all postsGET /api/posts/:id- Get post by IDPOST /api/posts- Create postPUT /api/posts/:id- Update postDELETE /api/posts/:id- Delete post
GET /api/comments- Get all commentsGET /api/comments/:id- Get comment by IDPOST /api/comments- Create commentPUT /api/comments/:id- Update commentDELETE /api/comments/:id- Delete comment
Run the test suite:
npm test