Last active
September 20, 2021 07:54
-
-
Save hoangsetup/980762cbb6a62c260590acd19105b61c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/server.ts | |
import * as http from 'http'; | |
import dotenv from 'dotenv'; | |
import app from './app'; | |
import mongoose from 'mongoose'; | |
import { initSocketIo } from './socket'; | |
(async () => { | |
dotenv.config(); | |
const server = http.createServer(app); | |
await mongoose.connect(process.env.MONGO_URI as string, { | |
useNewUrlParser: true, | |
useUnifiedTopology: true, | |
useCreateIndex: true, | |
}); | |
initSocketIo(server); | |
server.listen(process.env.PORT, () => { | |
console.log(`listening on *: ${process.env.PORT}`); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment