forked from b00tc4mp/isdi-bootcamp-202409
-
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.
install vite and com to api and app directory b00tc4mp#183
- Loading branch information
1 parent
f7eb5f5
commit 91379eb
Showing
538 changed files
with
66,126 additions
and
791 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { validate } from 'com' | ||
import { storage, uuid } from '../data/index.js' | ||
|
||
export default (userId, postId, text) => { | ||
validate.id(userId, 'userId') | ||
validate.id(postId, 'postId') | ||
validate.text(text) | ||
|
||
const { users, posts } = storage | ||
|
||
const found = users.some(({ id }) => id === userId) | ||
|
||
if (!found) throw new Error('user not found') | ||
|
||
const post = posts.find(({ id }) => id === postId) | ||
|
||
if (!post) throw new Error('post not found') | ||
|
||
const { comments } = post | ||
|
||
comments.push({ | ||
id: uuid(), | ||
author: userId, | ||
text, | ||
date: new Date().toISOString() | ||
}) | ||
|
||
storage.posts = posts | ||
} |
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 addComment from './addComment.js' | ||
|
||
try { | ||
addComment('m2vvw4xzn6d', 'm2vw4ucygv', 'wow!') | ||
} catch (error) { | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.