├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── index.js
├── kubernetes.yaml
├── package.json
├── public
├── buzzer-logo.svg
├── host.js
├── join.js
├── lets-play.png
└── style.css
├── screenshots
├── host-v3.png
├── player-buzzer-v3.png
└── player-join-v3.png
└── views
├── host.pug
└── index.pug
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:14-alpine
2 |
3 | RUN mkdir -p /usr/src/app
4 | WORKDIR /usr/src/app
5 |
6 | ENV NODE_ENV production
7 |
8 | COPY package.json /usr/src/app/
9 | RUN npm install
10 | COPY . /usr/src/app
11 |
12 | EXPOSE 8090
13 |
14 | CMD ["node", "./index.js"]
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Buffer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | A little buzzer app for running your own quizzes or game shows! Uses websockets to sent messages.
6 |
7 | ## Running the app
8 |
9 | You'll need [Node.js](https://nodejs.org) or [Docker](https://www.docker.com/) to run this
10 | application. For Node:
11 |
12 | ```
13 | npm install
14 | node index.js
15 | ```
16 |
17 | For Docker:
18 |
19 | ```
20 | docker build -t buzzer .
21 | docker run -p 8090:8090 buzzer
22 | ```
23 |
24 | Open http://localhost:8090 in your browser to start!
25 |
26 | ## How to use
27 |
28 | The players goto the homepage (`http://localhost:8090/`) and they can enter their name and team
29 | number. Joining will give them a giant buzzer button!
30 |
31 | The host heads over to `/host` and will be able to see everyone that buzzes in and clear the list
32 | in between questions.
33 |
34 | Join a team | Buzz in | Host view |
35 | :-------------------------:|:-------------------------:|:-------------------------:|
36 | | |
37 |
38 | ## License
39 |
40 | MIT
41 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const http = require('http')
2 | const express = require('express')
3 | const socketio = require('socket.io')
4 |
5 | const app = express();
6 | const server = http.Server(app);
7 | const io = socketio(server);
8 |
9 | const title = 'Buffer Buzzer'
10 |
11 | let data = {
12 | users: new Set(),
13 | buzzes: new Set(),
14 | }
15 |
16 | const getData = () => ({
17 | users: [...data.users],
18 | buzzes: [...data.buzzes].map(b => {
19 | const [ name, team ] = b.split('-')
20 | return { name, team }
21 | })
22 | })
23 |
24 | app.use(express.static('public'))
25 | app.set('view engine', 'pug')
26 |
27 | app.get('/', (req, res) => res.render('index', { title }))
28 | app.get('/host', (req, res) => res.render('host', Object.assign({ title }, getData())))
29 |
30 | io.on('connection', (socket) => {
31 | socket.on('join', (user) => {
32 | data.users.add(user.id)
33 | io.emit('active', [...data.users].length)
34 | console.log(`${user.name} joined!`)
35 | })
36 |
37 | socket.on('buzz', (user) => {
38 | data.buzzes.add(`${user.name}-${user.team}`)
39 | io.emit('buzzes', [...data.buzzes])
40 | console.log(`${user.name} buzzed in!`)
41 | })
42 |
43 | socket.on('clear', () => {
44 | data.buzzes = new Set()
45 | io.emit('buzzes', [...data.buzzes])
46 | console.log(`Clear buzzes`)
47 | })
48 | })
49 |
50 | server.listen(8090, () => console.log('Listening on 8090'))
51 |
--------------------------------------------------------------------------------
/kubernetes.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: buzzer
5 | labels:
6 | app: buzzer
7 | spec:
8 | replicas: 1
9 | template:
10 | metadata:
11 | labels:
12 | app: buzzer
13 | spec:
14 | containers:
15 | - name: buzzer
16 | image: bufferapp/buzzer:1.3.0
17 | ports:
18 | - containerPort: 8090
19 | resources:
20 | limits:
21 | cpu: 100m
22 | memory: 200Mi
23 | restartPolicy: Always
24 | ---
25 | apiVersion: v1
26 | kind: Service
27 | metadata:
28 | name: buzzer
29 | labels:
30 | app: buzzer
31 | spec:
32 | ports:
33 | - port: 80
34 | targetPort: 8090
35 | protocol: TCP
36 | name: http
37 | selector:
38 | app: buzzer
39 | type: LoadBalancer
40 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "buzzer",
3 | "version": "1.2.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "Dan Farrelly (http://danfarrelly.nyc)",
10 | "license": "MIT",
11 | "dependencies": {
12 | "express": "4.14.1",
13 | "pug": "2.0.0-beta11",
14 | "socketio": "1.0.0"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/public/buzzer-logo.svg:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/public/host.js:
--------------------------------------------------------------------------------
1 | const socket = io()
2 | const active = document.querySelector('.js-active')
3 | const buzzList = document.querySelector('.js-buzzes')
4 | const clear = document.querySelector('.js-clear')
5 |
6 | socket.on('active', (numberActive) => {
7 | active.innerText = `${numberActive} joined`
8 | })
9 |
10 | socket.on('buzzes', (buzzes) => {
11 | buzzList.innerHTML = buzzes
12 | .map(buzz => {
13 | const p = buzz.split('-')
14 | return { name: p[0], team: p[1] }
15 | })
16 | .map(user => `