The Planted project purpose is to assist users by collecting data from a variety of sensors ex. humidity, temperature, sunlight, and soil moister. This in hopes of helping users to keep their plants alive and thriving. Sensors send data to the server and the React Native app visualizes the data
Planted Github | Hardware Side | Front End
- Ashley Parker React Wizard|Developer
- Illia Chaban Backend|Database|Chart Wizard|Developer
- Nick Wilson Hardware/Electrician|Developer
- React Native
- React
- Redux
- D3
- Node
- GraphQL
- PostgreSQL
- Javascript
- Heroku
- Python
router.post('/register', async (req, res) => {
let userInfo = await readBody(req).then(data => JSON.parse(data))
let { avatar, username, email, password } = userInfo
let hash = await bcrypt.hash(password, 10);
await db.query(`
INSERT INTO users (
username, email, passw, avatar
)
VALUES (
'${username}',
'${email}',
'${hash}',
'${avatar}'
);`)
.catch(err => console.log(err))
let user = await findUserByEmail(db, email);
let token = createToken(user);
res.end(token);
})
router.post('/graphql', async (req, res) => {
let { authorization: token } = req.headers;
try {
let payload = jwt.verify(token, signature);
let userid = payload.userid;
let query = await readBody(req)
let results = await getResults(query, userid);
res.send(results)
} catch (err) {
console.log("POST GRAPHQL - ERROR ####", err)
res.status(401).end('Unauthorized')
}
})
module.exports = router;
fetch('https://planted-dc.herokuapp.com/graphql', {
headers: {
"authorization": token,
},
method: 'POST',
body: `
query {
currentUser {
user {
username
avatar
}
plantData {
temp
sun
moist
humidity
created
}
}
}`
})
.then( res => res.json() ).then(console.log)
#############
fetch('https://planted-dc.herokuapp.com/graphql', {
headers: {
"authorization": token,
},
method: 'POST',
body: `
query {
currentUser {
getPlantDataFor(hours: 3) {
temp
sun
moist
humidity
created
}
}
}`
})
.then( res => res.json() ).then(console.log)
###############
fetch('https://planted-dc.herokuapp.com/graphql', {
headers: {
"authorization": token,
},
method: 'POST',
body: `
mutation {
addPlantData(input: {temp: 70 sun: 300 moist: 24 humidity: 3.2 }) {
userid
}
}
`
})
.then( res => res.json() ).then(console.log)