-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: errors with dbconfig and mongoose models
- Loading branch information
Showing
1 changed file
with
6 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import dbConfig from "../db"; | ||
import dbConfig from "@utils/db"; | ||
import { sendEmail } from "../email"; | ||
import { render } from "@react-email/render"; | ||
import { UserActivityTemplate } from "../emails/templates"; | ||
import { UserLog } from "@models/index"; | ||
|
||
type userlogType = { | ||
username: string; | ||
|
@@ -12,11 +13,9 @@ type userlogType = { | |
}; | ||
|
||
async function logUserActivity(userlog: userlogType, req: Request) { | ||
const db = await dbConfig(); | ||
await dbConfig(); | ||
|
||
try { | ||
const logs_collection = db.collection("user_logs"); | ||
|
||
const user_log = { | ||
username: userlog.username, | ||
name: userlog.name, | ||
|
@@ -32,7 +31,9 @@ async function logUserActivity(userlog: userlogType, req: Request) { | |
}; | ||
|
||
//stores in user_logs | ||
await logs_collection.insertOne(user_log); | ||
const logs = new UserLog(user_log); | ||
|
||
await logs.save(); | ||
|
||
await sendEmail({ | ||
to: process.env.LOGGER_EMAIL || "[email protected]", | ||
|