Skip to content

Commit

Permalink
fix: errors with dbconfig and mongoose models
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed Jul 1, 2024
1 parent 2e84675 commit 4bfc5eb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/app/lib/logs/index.tsx
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;
Expand All @@ -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,
Expand All @@ -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]",
Expand Down

0 comments on commit 4bfc5eb

Please sign in to comment.