File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
- // server file
1
+ // server file
2
+ import express from "express" ;
3
+ import { Server } from "socket.io" ;
4
+ import { createServer } from "http" ;
5
+
6
+ const app = express ( ) ;
7
+ const server = createServer ( app ) ;
8
+ const io = new Server ( server ) ;
9
+ const PORT = 8080 ;
10
+
11
+ app . get ( '/' , ( req , res ) => {
12
+ console . log ( 'running' )
13
+ } )
14
+
15
+ io . on ( 'connection' , ( socket ) => {
16
+ console . log ( 'user connected socket' )
17
+ } )
18
+
19
+ app . listen ( PORT , ( ) => {
20
+ console . log ( `server running on ${ PORT } ` )
21
+ } )
Original file line number Diff line number Diff line change 3
3
"version" : " 1.0.0" ,
4
4
"description" : " " ,
5
5
"main" : " index.js" ,
6
+ "type" : " module" ,
6
7
"scripts" : {
7
8
"test" : " echo \" Error: no test specified\" && exit 1" ,
8
9
"server" : " nodemon index.js"
You can’t perform that action at this time.
0 commit comments