Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 8x 38x 28x 8x 8x 48x | import { http, HttpResponse } from 'msw'
import { mockProjects, mockPipelines } from '@/msw/mock-data'
function getProject(id: string) {
return mockProjects.find((p) => p.id === id) ?? mockProjects[0]
}
export const projectHandlers = [
http.get('/api/v1/projects', () =>
HttpResponse.json({
data: mockProjects,
meta: { limit: 50, returned: mockProjects.length, has_more: false },
}),
),
http.get('/api/v1/projects/:id', ({ params }) => {
const project = getProject(params.id as string)
return HttpResponse.json({
project,
pipelines: mockPipelines.filter((p) => p.project_id === project.id),
})
}),
http.post('/api/v1/projects', () =>
HttpResponse.json({ ...mockProjects[0], id: 'proj-new', name: 'New Project' }, { status: 201 }),
),
http.put('/api/v1/projects/:id', ({ params }) =>
HttpResponse.json(getProject(params.id as string)),
),
http.delete('/api/v1/projects/:id', () => new HttpResponse(null, { status: 204 })),
]
|