-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.ts
48 lines (41 loc) · 1.26 KB
/
server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// import dotenv from 'dotenv'
// import mongoose from 'mongoose'
// import app from './app'
// dotenv.config({ path: './.env.test' })
// export interface EnvConfig {
// PORT: string | number
// DATABASE: string
// DATABASE_PASSWORD: string
// }
// const { PORT, DATABASE, DATABASE_PASSWORD } =
// process.env as unknown as EnvConfig
// const DB = DATABASE.replace('<PASSWORD>', DATABASE_PASSWORD)
// mongoose
// .connect(DB, {
// useNewUrlParser: true,
// useCreateIndex: true,
// useFindAndModify: false,
// useUnifiedTopology: true,
// })
// .then(() => {
// console.log('DB connection established')
// })
// .catch((err) => {
// console.error('DB connection failed:', err)
// })
// const server = app.listen(PORT, () => {
// console.log(`App running on port ${PORT}...`)
// })
// process.on('unhandledRejection', (err: Error) => {
// console.error('Unhandled Rejection. Shutting down...', err)
// server.close(() => {
// process.exit(1)
// })
// })
// // Handle uncaught exceptions
// process.on('uncaughtException', (err: Error) => {
// console.error('Uncaught Exception. Shutting down...', err)
// server.close(() => {
// process.exit(1)
// })
// })