Skip to content

Commit

Permalink
install vite and com to api and app directory b00tc4mp#183
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudi1991 committed Nov 5, 2024
1 parent f7eb5f5 commit 91379eb
Show file tree
Hide file tree
Showing 538 changed files with 66,126 additions and 791 deletions.
29 changes: 29 additions & 0 deletions staff/claudi-cano/unsocial/api/logic/addComment.js
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
}
7 changes: 7 additions & 0 deletions staff/claudi-cano/unsocial/api/logic/addComment.test.js
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)
}
5 changes: 1 addition & 4 deletions staff/claudi-cano/unsocial/api/logic/authenticateUser.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { storage } from '../data/index.js'
import validate from './helpers/validate.js'
import { validate } from 'com'

export default (username, password) => {
validate.username(username)
validate.password(password)

if (password.length < 8)
throw new Error('invalid password')

const { users } = storage

const user = users.find(user => user.username === username && user.password === password)
Expand Down
16 changes: 16 additions & 0 deletions staff/claudi-cano/unsocial/api/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions staff/claudi-cano/unsocial/api/node_modules/.bin/mime.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions staff/claudi-cano/unsocial/api/node_modules/.bin/mime.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 91379eb

Please sign in to comment.