Skip to content

Commit

Permalink
adding starting project
Browse files Browse the repository at this point in the history
  • Loading branch information
Si Choi authored and Si Choi committed Apr 29, 2020
1 parent 109cacb commit 187bfc9
Show file tree
Hide file tree
Showing 3,541 changed files with 317,142 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions controller/image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Clarifai = require ('clarifai');

const app = new Clarifai.App({
apiKey: '6d96bc98d0814d10837c8456301b5c1a'
});

const handleApiCall = (req, res) =>{
app.models.predict(Clarifai.FACE_DETECT_MODEL, req.body.input)
.then(data => {
res.json(data);
})
.catch(err => res.status(400).json('unable to work with api'))
}

const handleImage = (req, res, db) => {
const { id } = req.body;
db('users').where('id', '=', id)
.increment('entries', 1)
.returning('entries')
.then(entries => {
res.json(entries[0]);
})
.catch(err => res.status(400).json('unable to get entries'))
}

module.exports = {
handleImage : handleImage,
handleApiCall : handleApiCall
}
19 changes: 19 additions & 0 deletions controller/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const handleProfile = (req, res) => {
const { id } = req.params;
db.select('*').from('users').where({id})
.then(user => {
if(user.length){
res.json(user[0])
} else {
res.status(400).json('Not found')
}
})
.catch(err => res.status(400).json('error getting user data'))
// if (!found) {
// res.status(400).json('not found');
// }
}

module.exports = {
handleProfile: handleProfile
}
34 changes: 34 additions & 0 deletions controller/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const handleRegister = (req, res, db, bcrypt) => {
const { email, name, password } = req.body;
if(!email || !name || !password){
return res.status(400).json('incorrect submission form');
}
const hash = bcrypt.hashSync(password);
db.transaction(trx => {
trx.insert({
hash: hash,
email: email
})
.into('login')
.returning('email')
.then(loginEmail => {
return trx('users')
.returning('*')
.insert({
email: loginEmail[0],
name: name,
joined: new Date()
})
.then(user => {
res.json(user[0]);
})
})
.then(trx.commit)
.catch(trx.rollback)
})
.catch(err => res.status(400).json('unable to register'))
}

module.exports = {
handleRegister: handleRegister
}
26 changes: 26 additions & 0 deletions controller/signin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const handleSignin = (req, res, db, bcrypt) => {
const { email, password } = req.body;
if(!email || !password){
return res.status(400).json('incorrect submission form');
}
db.select('email', 'hash').from('login')
.where('email', '=', email)
.then(data => {
const isValid = bcrypt.compareSync(password, data[0].hash);
if(isValid) {
return db.select('*').from('users')
.where('email', '=', email)
.then(user => {
res.json(user[0]);
})
.catch(err => res.status(400).json('unable to get user'))
} else {
res.status(400).json('wrong credentials')
}
})
.catch(err => res.status(400).json('wrong credentials'))
}

module.exports = {
handleSignin : handleSignin
}
1 change: 1 addition & 0 deletions node_modules/.bin/atob

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

1 change: 1 addition & 0 deletions node_modules/.bin/is-ci

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

1 change: 1 addition & 0 deletions node_modules/.bin/knex

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

1 change: 1 addition & 0 deletions node_modules/.bin/mime

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

1 change: 1 addition & 0 deletions node_modules/.bin/mkdirp

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

1 change: 1 addition & 0 deletions node_modules/.bin/nodemon

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

1 change: 1 addition & 0 deletions node_modules/.bin/nodetouch

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

1 change: 1 addition & 0 deletions node_modules/.bin/nopt

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

1 change: 1 addition & 0 deletions node_modules/.bin/rc

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

1 change: 1 addition & 0 deletions node_modules/.bin/semver

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

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

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

1 change: 1 addition & 0 deletions node_modules/.bin/which

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

46 changes: 46 additions & 0 deletions node_modules/abbrev/LICENSE

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

23 changes: 23 additions & 0 deletions node_modules/abbrev/README.md

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

61 changes: 61 additions & 0 deletions node_modules/abbrev/abbrev.js

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

56 changes: 56 additions & 0 deletions node_modules/abbrev/package.json

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

Loading

0 comments on commit 187bfc9

Please sign in to comment.