Skip to content

Commit ce14db3

Browse files
committed
init mongoose func
1 parent 4810eb8 commit ce14db3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import express from "express";
44
import * as config from "./config";
55
import Router from "./routes/router";
6+
import { initMongoose } from "./libs/mongoose/init";
67

78
const app: express.Application = express();
89

@@ -13,6 +14,8 @@ app.use("/", Router);
1314

1415
app.listen(config.server.port, () => {
1516
console.log(
16-
`[AUTH SERVER] Listening on http://0.0.0.0:${config.server.port}/`
17+
`[AUTH SERVER] EVENT --> Listening on http://0.0.0.0:${config.server.port}/`
1718
);
1819
});
20+
21+
initMongoose();

src/libs/mongoose/init.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
3+
import mongoose from "mongoose";
4+
import * as config from "../../config";
5+
6+
export async function initMongoose() {
7+
await mongoose
8+
.connect(config.tokens.mongo)
9+
.then(() => {
10+
console.log(
11+
`[AUTH SERVER] EVENT --> Mongoose connected to ${config.tokens.mongo}`
12+
);
13+
})
14+
.catch((err) => {
15+
console.error(`[AUTH SERVER] MONGOOSE ERROR --> `, err);
16+
});
17+
}

0 commit comments

Comments
 (0)