Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/[auth]/signin/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function Signin()
{
return <div>

<div className="text-white bg-black">
hey there from signin
</div>
</div>
}
17 changes: 17 additions & 0 deletions app/[auth]/signup/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use client"
import Navbar from "@/src/components/Navbar/Navbar";
export default function Signup()
{
return <div>

<div className="flex flex-row justify-center">
<div className="bg-black">
<p>hey there</p>
</div>
<div className="bg-blue-600">
<p className="text-black">hey there</p>
</div>
<a href="http://localhost:5173/api/auth/google">something</a>
</div>
</div>
}
2 changes: 1 addition & 1 deletion app/globals.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

@import "tailwindcss";
:root {
--dark-bg: #000;
--light-bg: #f6f7fbad;
Expand Down
5 changes: 4 additions & 1 deletion app/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Josef = Josefin_Sans({
weight : ["100","200","300","400","500","600","700"],
display : "swap"
})
// ...existing code...
export default function RootLayout({ children }) {
return (
<html lang="en">
Expand All @@ -26,7 +27,9 @@ export default function RootLayout({ children }) {
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css"
/>
</head>
<body className={Josef.className}>{children}</body>
<body className={Josef.className} style={{ background: 'white', color: 'black' }}>
{children}
</body>
</html>
);
}
2 changes: 2 additions & 0 deletions backend/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DB_URL=""
JWT=""
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
node_modules
12 changes: 12 additions & 0 deletions backend/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import express from "express"
import dotenv from "dotenv"
import mongoose from "mongoose"
import AuthRouter from "./routes/index.ts"
import cors from "cors"
dotenv.config();
const app=express()
app.use(cors())
app.use("/api",AuthRouter);
mongoose.connect(process.env.DB_URL!)
.then(()=>{console.log("Connected")})
app.listen(5173)
28 changes: 28 additions & 0 deletions backend/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import jwt from "jsonwebtoken"
import dotenv from "dotenv"
dotenv.config()

export default function Authmiddleware(req,res,next)
{
const authheader = req.headers.authorization;
if(!authheader || !authheader.startsWith("Bearer "))
{
return res.status(402).json({
message:"NO Token Found"
})
}
const token=authheader.split(" ")[1]
try{
const decoded=jwt.verify(token,process.env.JWT)
if (typeof decoded === "object" && "userid" in decoded) {
req.userid = (decoded as any).userid;
}
next();
}
catch(e)
{
return res.status(403).json({
e
})
}
}
53 changes: 53 additions & 0 deletions backend/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import mongoose, { Schema } from "mongoose"
import dotenv from "dotenv"
dotenv.config()
mongoose.connect(process.env.DB_URL!)
interface Auth
{
email:string,
password:string,
name:string,
username:string,
googleid:string
}
const SignupSchema:Schema<Auth>= new Schema(
{
name: {
type: String,
required: function() {

return !this.googleid;
}
},
username: {
type: String,
unique: true,
sparse: true
},
email: {
type: String,
required: function() {

return !this.googleid;
},
unique: true,
sparse: true
},
password: {
type: String,
minlength: 3,
maxlength: 12,
required: function() {

return !this.googleid;
}
},
googleid: {
type: String,
unique: true,
sparse: true
}
}
)
const Signup=mongoose.model<Auth>("Signup",SignupSchema)
export{Signup}
Loading