Squash Tomato Journal — November 12, 2017–11:30

Chris Johnson
The Squash and the Tomato
1 min readNov 14, 2017
  1. Organized the future functionality of family lists
  2. Searched for realtime solutions for my user interface. I wanted users of the same list to see the changes another was making as soon as they changed them. I came upon WebSockets. Although I’d like to use the barebones WebSockets’ API, I’m using Socket.io for speed since I’m up against a deadline!
  3. Went through the Socket.io tutorial — Someone is clearly more intelligent than I am 😆
  4. Began to integrate Socket.io into Squash Tomato on a git feature branch (separated from master, which controls what’s running on my server)
const mongoose = require('mongoose');// import env variablesrequire('dotenv').config({ path: 'variables.env' });// connect to our database and handle bad connectionsmongoose.connect(process.env.LOCAL_DATABASE);mongoose.Promise = global.Promise; // tell mongoose to use es6 promisesmongoose.connection.on('error', (err) => {    console.log(`Shit! Fuck! It's not working! 😡😡😡 → ${err.message}`);});// Les do it, bitches!require('./models/User');require('./models/SharedList');const http = require('http');const app = require('./app');const server = http.createServer(app);const io = require('socket.io').listen(server);server.listen(process.env.LOCAL_PORT || 27017, () => {    console.log(`Express is running 👉🏻  ${process.env.LOCAL_PORT || 27017}`);});io.on('connection', (socket) => {    socket.emit('news', { hello: 'world' });});

--

--

Chris Johnson
The Squash and the Tomato

Full-stack Surgeon (Design, Vue, Node, mongoDB), knowledge seeker, world dominator, Harry Potter and anime addict, volleyball player, and unfiltered.