Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
# Shot Bot
# Beverage Bot

## Overview
A service running on Raspberry Pi which pours shots when triggered over the internet.
A service running on Raspberry Pi which pours beverages when triggered over the internet.

### Liquors
- Dark rum
- Vodka
- Gin
- Cointreau

### Mixers
- Tonic
- Coke
- Lemonade
- Ginger beer
- Lime juice

### Beverages
- Cuba Libre
- Gin & Tonic
- Moscow Mule
- Dark & Stormy
- Gin/Vodka Margarita
- & more...

## Prerequisites

Expand Down
159 changes: 159 additions & 0 deletions docs/postman/user-registration.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"info": {
"_postman_id": "4b754e10-0098-4aa8-aaa7-00ea325549d3",
"name": "Mongo User Registration",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Create user",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Laura\",\n\t\"email\": \"me@laurabrandon.codes\",\n\t\"password\": \"pre hashed password\",\n\t\"tokens\": {\n\t\t\"token\": \"WinterIsComing\"\n\t}\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/users",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"users"
]
}
},
"response": []
},
{
"name": "User login",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n\t\"email\": \"me@laurabrandon.codes\",\n\t\"password\": \"pre hashed password\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/users/login",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"users",
"login"
]
}
},
"response": []
},
{
"name": "User logout",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIwZTAwNjQ4YTdlYTI4MGRlZWI5N2QiLCJpYXQiOjE1ODg2NTM4NzZ9.PhrWofT8bKk-e7GCtczur1mhnPNVET3MEqAa--RN-t0",
"type": "text"
}
],
"url": {
"raw": "http://localhost:3000/users/me/logout?Authorization=Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIwZTAwNjQ4YTdlYTI4MGRlZWI5N2QiLCJpYXQiOjE1ODg2NDk5OTB9.2Ol6M49XpSeFFXMlSf8AxeVwQ2oCA8KxDPUxR9WxKlU",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"users",
"me",
"logout"
],
"query": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIwZTAwNjQ4YTdlYTI4MGRlZWI5N2QiLCJpYXQiOjE1ODg2NDk5OTB9.2Ol6M49XpSeFFXMlSf8AxeVwQ2oCA8KxDPUxR9WxKlU"
}
]
}
},
"response": []
},
{
"name": "User logout all",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIwZTAwNjQ4YTdlYTI4MGRlZWI5N2QiLCJpYXQiOjE1ODg2NDk5OTB9.2Ol6M49XpSeFFXMlSf8AxeVwQ2oCA8KxDPUxR9WxKlU"
}
],
"url": {
"raw": "http://localhost:3000/users/me/logoutall?Authorization=Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIwZTAwNjQ4YTdlYTI4MGRlZWI5N2QiLCJpYXQiOjE1ODg2NDk5OTB9.2Ol6M49XpSeFFXMlSf8AxeVwQ2oCA8KxDPUxR9WxKlU",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"users",
"me",
"logoutall"
],
"query": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIwZTAwNjQ4YTdlYTI4MGRlZWI5N2QiLCJpYXQiOjE1ODg2NDk5OTB9.2Ol6M49XpSeFFXMlSf8AxeVwQ2oCA8KxDPUxR9WxKlU"
}
]
}
},
"response": []
},
{
"name": "Get user",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIwZTAwNjQ4YTdlYTI4MGRlZWI5N2QiLCJpYXQiOjE1ODg2NTM4NzZ9.PhrWofT8bKk-e7GCtczur1mhnPNVET3MEqAa--RN-t0",
"type": "text"
}
],
"url": {
"raw": "http://localhost:3000/users/me",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"users",
"me"
]
}
},
"response": []
}
],
"protocolProfileBehavior": {}
}
6 changes: 3 additions & 3 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pi-shot-bot",
"name": "pi-beverage-bot",
"version": "1.0.0",
"description": "A bot which pours shots for you when triggered",
"description": "A bot which pours beverages when triggered",
"main": "app.js",
"scripts": {
"start": "env-cmd -f ./.env nodemon src/app.js",
Expand All @@ -16,9 +16,9 @@
"author": "Laura Brandon",
"license": "ISC",
"bugs": {
"url": "https://github.com/explaura/pi-shot-bot/issues"
"url": "https://github.com/explaura/pi-beverage-bot/issues"
},
"homepage": "https://github.com/explaura/pi-shot-bot#readme",
"homepage": "https://github.com/explaura/pi-beverage-bot#readme",
"dependencies": {
"onoff": "^6.0.0",
"bcryptjs": "^2.4.3",
Expand Down
6 changes: 3 additions & 3 deletions src/models/Hardware.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const mongoose = require('mongoose');
const Gpio = require('onoff').Gpio;
const led = new Gpio(17, 'out');
const pump = new Gpio(17, 'out');

const hardwareSchema = mongoose.Schema();

hardwareSchema.statics.toggleLed = async function () {
return led.writeSync(led.readSync() ^ 1);
hardwareSchema.statics.togglePump = async function () {
return pump.writeSync(pump.readSync() ^ 1);
};

const Hardware = mongoose.model('Hardware', hardwareSchema);
Expand Down
15 changes: 15 additions & 0 deletions src/pumps/pump-layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"pumps": [
{
"dark-rum": 1,
"vodka": 2,
"gin": 3,
"cointreau": 4,
"tonic": 5,
"coke": 6,
"lemonade": 7,
"ginger-beer": 8,
"lime-juice": 9
}
]
}
24 changes: 24 additions & 0 deletions src/recipes/beverages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"beverages": [
{
"cuba-libre": {
"name": "Cuba Libre"
},
"gin-and-tonic": {
"name": "Gin & Tonic"
},
"moscow-mule": {
"name": "Moscow Mule"
},
"dark-and-stormy": {
"name": "Dark & Stormy"
},
"gin-margarita": {
"name": "Gin Margarita"
},
"vodka-margarita": {
"name": "Vodka Margarita"
}
}
]
}
4 changes: 2 additions & 2 deletions src/routers/hardware.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const auth = require('../middleware/auth');

const router = express.Router();

router.post('/hardware/led', auth, async (req, res) => {
router.post('/hardware/pump', auth, async (req, res) => {
try {
await Hardware.toggleLed();
await Hardware.togglePump();
res.status(200);
} catch (error) {
res.status(500).send(error);
Expand Down