mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 22:27:48 +00:00
Added:
- Added Midleware to capture and handle all errors
- will catch error from `throw ...` and `next(...)`
- Added RequestError base error class to build consistent error objects
- Added common errors like `UnauthorizedRequestError`, `BadRequestError`
- Added consistent Logging solution using `winston`
- Supports Loki Transporter using `winston-loki`
- Outputing Legal disclaimer to console when `TELEMETRY_ENABLED=true`
Changed:
- Changed console.log to getLogger() favor of using consistent logging
11 lines
394 B
TypeScript
11 lines
394 B
TypeScript
import mongoose from 'mongoose';
|
|
import { getLogger } from '../utils/logger';
|
|
|
|
export const initDatabase = (MONGO_URL: string) => {
|
|
mongoose
|
|
.connect(MONGO_URL)
|
|
.then(() => getLogger("database").info("Database connection established"))
|
|
.catch((e) => getLogger("database").error(`Unable to establish Database connection due to the error.\n${e}`));
|
|
return mongoose.connection;
|
|
};
|