-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from detached/feature/comments
Implements comments for recipes
- Loading branch information
Showing
59 changed files
with
12,008 additions
and
21,043 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { http } from 'msw' | ||
import {getComments, postComment} from "./resolver/comments"; | ||
|
||
export const handlers = [ | ||
http.get('/api/comments/recipe/*', getComments), | ||
http.post("/api/comments/recipe/*", postComment) | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { setupServer } from 'msw/node' | ||
import { handlers } from './handlers.js' | ||
|
||
export const server = setupServer(...handlers); | ||
|
||
server.events.on('response:mocked', ({ request, response }) => { | ||
console.log( | ||
'%s %s received %s %s', | ||
request.method, | ||
request.url, | ||
response.status, | ||
response.statusText | ||
) | ||
}); | ||
|
||
server.events.on('unhandledException', ({ request, error }) => { | ||
console.log('%s %s errored! See details below.', request.method, request.url) | ||
console.error(error) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {HttpResponse} from "msw"; | ||
|
||
export const getComments = () => { | ||
return HttpResponse.json({ | ||
comments: [ | ||
{ | ||
id: 'commentId1', | ||
author: { | ||
id: 'authorId1', | ||
name: 'Author 1' | ||
}, | ||
comment: 'That is comment 1', | ||
createdOn: '1970-01-01', | ||
canDelete: true | ||
}, | ||
{ | ||
id: 'commentId2', | ||
author: { | ||
id: 'authorId2', | ||
name: 'Author 2' | ||
}, | ||
comment: 'That is comment 2', | ||
createdOn: '1970-01-02', | ||
canDelete: false | ||
} | ||
] | ||
}); | ||
} | ||
|
||
export const postComment = () => { | ||
return HttpResponse.json( | ||
{ | ||
id: 'newCommentId', | ||
author: { | ||
id: 'authorId1', | ||
name: 'Author 1' | ||
}, | ||
comment: 'That is comment 1', | ||
createdOn: '1970-01-01', | ||
canDelete: true | ||
} | ||
) | ||
} |
Oops, something went wrong.