trollbox
Instant trollbox using Firebase.
Demo
https://lab.miguelmota.com/trollbox
Install
npm install trollbox
Instructions
-
Create a new Firebase project.
-
Set read/write rules to be global in Firebase.
Firebase dashboard console -> Database -> Rules
{
"rules": {
".read": true,
".write": true
}
}
- Set up HTML container:
<div id="trollbox"></div>
- Copy Firebase project config from dashboard and initialize trollbox:
const Trollbox = require('trollbox')
const config = {
container: '#trollbox',
firebase: {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxx-xxxxx.firebaseapp.com',
databaseURL: 'https://xxxxxxxx-xxxxx.firebaseio.com',
projectId: 'xxxxxxxx-xxxxx',
storageBucket: 'xxxxxxxx-xxxxx.appspot.com',
messagingSenderId: 'xxxxxxxxxxxx'
},
channel: 'global',
user: 'anon'
}
const trollbox = new Trollbox(config)
-
Copy base trollbox.css stylesheet into your web app.
-
That's it!
Later on if you need to, you can change the channel name and user:
trollbox.setChannel('random')
trollbox.setUser('Bob')
You can also completely destroy the trollbox:
trollbox.destroy()
License
MIT