H
H
hckn2018-09-04 01:14:03
Node.js
hckn, 2018-09-04 01:14:03

How to make Express routes on a server with socket.io?

Connected socket.io to Express base server.

const express = require('express')
const app = express()
const server = require('http').createServer(app)
const io = require('socket.io')(server)

io.on('connection', socket => {
  ...
})

server.listen(9090)

Previously, I did not use the module httpwith Express and it is not entirely clear how I can now have regular routes in this configuration, likeserver.get('/hello')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Hellsite, 2018-09-04
@hckn

Just:
app.get('/hello', () => {...});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question