-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from sanam2405/loc
synchronise Postgres and MongoDB
- Loading branch information
Showing
27 changed files
with
13,651 additions
and
156 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
27 changes: 0 additions & 27 deletions
27
backend/loc/prisma/migrations/20240421103750_init/migration.sql
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
backend/loc/prisma/migrations/20240428092122_dbseed/migration.sql
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- CreateTable | ||
CREATE TABLE "Location" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"latitude" DOUBLE PRECISION NOT NULL, | ||
"longitude" DOUBLE PRECISION NOT NULL, | ||
"createdAt" TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(6) NOT NULL, | ||
|
||
CONSTRAINT "Location_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"name" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"age" DOUBLE PRECISION NOT NULL, | ||
"gender" TEXT NOT NULL, | ||
"college" TEXT NOT NULL, | ||
"isVisible" BOOLEAN NOT NULL, | ||
"locationId" UUID, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "User" ADD CONSTRAINT "User_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Location"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
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
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Request, Response, NextFunction } from "express"; | ||
import HttpStatusCode from "../types/HttpStatusCode"; | ||
import bcrypt from "bcryptjs"; | ||
|
||
export const interBackendAccess = async ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction, | ||
) => { | ||
const { authorization } = req.headers; | ||
|
||
try { | ||
if (!authorization) { | ||
return res | ||
.status(HttpStatusCode.UNAUTHORIZED) | ||
.send({ errors: "You are unauthorized to access this resource" }); | ||
} | ||
|
||
if (!process.env.BACKEND_INTERCOMMUNICATION_SECRET) { | ||
console.error( | ||
"BACKEND_INTERCOMMUNICATION_SECRET is undefined. Check the .env", | ||
); | ||
return res | ||
.status(HttpStatusCode.INTERNAL_SERVER_ERROR) | ||
.send({ errors: "Internal Server Error" }); | ||
} | ||
|
||
const token = authorization.replace("Bearer ", ""); | ||
|
||
const isMatch = bcrypt.compareSync( | ||
process.env.BACKEND_INTERCOMMUNICATION_SECRET, | ||
token, | ||
); | ||
|
||
if (!isMatch) { | ||
return res | ||
.status(HttpStatusCode.UNAUTHORIZED) | ||
.send({ errors: "You are unauthorized to access this resource" }); | ||
} | ||
|
||
next(); | ||
} catch (error) { | ||
console.error(error); | ||
return res | ||
.status(HttpStatusCode.UNAUTHORIZED) | ||
.send({ errors: "You must be logged in" }); | ||
} | ||
}; |
Oops, something went wrong.
9388c33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
privacy-network – ./
privacy-network.vercel.app
privacy-network-git-main-manas-pratim-biswas-projects.vercel.app
privacy-network-manas-pratim-biswas-projects.vercel.app
privacynetwork.manaspratimbiswas.com