-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathindex.ts
More file actions
41 lines (32 loc) · 1005 Bytes
/
index.ts
File metadata and controls
41 lines (32 loc) · 1005 Bytes
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
require('dotenv').config();
import mongodb from 'mongodb';
import ImageKit from 'imagekit';
const port = process.env.PORT || 8080;
const user = process.env.DB_USER;
const password = process.env.DB_PASS;
const host = process.env.DB_HOST;
const publicKey = process.env.IMAGEKIT_PUBLIC_KEY as string;
const privateKey = process.env.IMAGEKIT_PRIVATE_KEY as string;
const urlEndpoint = process.env.IMAGEKIT_URLENDPOINT as string;
const MongoClient = mongodb.MongoClient;
const uri = `mongodb+srv://${user}:${password}@${host}`;
//const uri = `mongodb://localhost:27017`;
export const imagekit = new ImageKit({
publicKey,
privateKey,
urlEndpoint,
});
export const mongoService = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const retryConnection = () => {
mongoService.connect().catch((e) => {
console.error(e);
});
};
retryConnection();
import app from './app';
app.listen(port, () => {
console.log(`server started at http://localhost:${port}`);
});