Skip to content

Commit

Permalink
Merge pull request #23 from EdVentureDev/main
Browse files Browse the repository at this point in the history
Updating Prod branch
  • Loading branch information
HarshitShukla-dev authored Jul 15, 2024
2 parents 2677966 + 3a4638d commit 2b77774
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 135 deletions.
92 changes: 0 additions & 92 deletions Backend/package-lock.json

This file was deleted.

19 changes: 0 additions & 19 deletions Backend/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion Backend/src/Routes/OTP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dotenv.config();
let transporter = nodemailer.createTransport({
host: "smtp.naver.com",
port: 587,
secure: false, // upgrade later with STARTTLS
secure: false,
auth: {
user: process.env.EMAIL_USERNAME,
pass: process.env.EMAIL_PASSWORD,
Expand Down
2 changes: 1 addition & 1 deletion Backend/src/Routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import argon from "argon2";
import { User } from "../db";
import { getGeneratedOTP, sendOTP } from "./OTP";
import jwt from "jsonwebtoken"
import JWT_SECRET from "../config";
const JWT_SECRET = require( "../config");
const router = express.Router();

async function hashPassword(password: string) {
Expand Down
11 changes: 9 additions & 2 deletions Backend/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const JWT_SECRET = "MYSECRETKEY"
const path = require("path")
const dotenv = require("dotenv");

export default JWT_SECRET;
dotenv.config({ path: path.join(process.cwd(), "..", ".env") })

const port = process.env.PORT;
const dbURL = process.env.DATABASE_URL;
const JWT_SECRET = "MYSECRETKEY";

module.exports = { port, dbURL, JWT_SECRET };
29 changes: 12 additions & 17 deletions Backend/src/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
require('dotenv').config();
import mongoose from "mongoose";
const env = require("../config");
import mongoose from 'mongoose';

const databaseUrl = process.env.DATABASE_URL;

if (!databaseUrl) {
if (!env.dbURL) {
throw new Error('DATABASE_URL is not defined in the environment variables');
}

mongoose.connect(databaseUrl)
mongoose.connect(env.dbURL)
.then(() => console.log('Database connected successfully'))
.catch(err => console.error('Database connection error:', err));


const UserSchema = new mongoose.Schema({
firstName: String,
lastName: String,
Expand All @@ -20,8 +18,7 @@ const UserSchema = new mongoose.Schema({
educational_institute: String,
password: String,
groups: [],

})
});

const GroupsSchema = new mongoose.Schema({
createdBy: String,
Expand All @@ -30,18 +27,16 @@ const GroupsSchema = new mongoose.Schema({
messages: [{
sentBy: String,
content: String,
time: Date
time: Date,
}],
})
});

const ConversationSchema = new mongoose.Schema({
first: String,
second: String,
msgs: {

}
})
msgs: {},
});

export const User= mongoose.model("User", UserSchema)
export const Group = mongoose.model("Group",GroupsSchema)
export const Convo = mongoose.model("Conversations",ConversationSchema)
export const User = mongoose.model('User', UserSchema);
export const Group = mongoose.model('Group', GroupsSchema);
export const Convo = mongoose.model('Conversations', ConversationSchema);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<div id="leftUsername">
<div class="name">
Harshit Shukla
itsUser1
</div>
<div class="status">
<div class="dot"></div>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"otp-generator": "^4.0.1",
"typescript": "^5.5.3",
"ws": "^8.16.0",
"zod": "^3.22.4"
},
"zod": "^3.22.4",
"typescript": "^5.4.5"
"devDependencies": {
"@types/cookie-parser": "^1.4.7",
"cookie-parser": "^1.4.6"
Expand Down

0 comments on commit 2b77774

Please sign in to comment.