-
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.
- Loading branch information
Showing
11 changed files
with
232 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Keep environment variables out of version control | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,70 @@ | ||
-- CreateEnum | ||
CREATE TYPE "ActionType" AS ENUM ('CREATE', 'VIEW', 'DELETE'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "Repository" AS ENUM ('VAULT', 'EXHIBIT_SHARE'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "ActionableType" AS ENUM ('FILE', 'FOLDER'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "ActivityType" AS ENUM ('CREATED', 'VIEWED', 'DOWNLOADED', 'MOVED', 'DELETED', 'RENAMED'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL, | ||
"admin" BOOLEAN NOT NULL DEFAULT false, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Activity" ( | ||
"id" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
"activityType" "ActivityType" NOT NULL, | ||
"actionableType" "ActionableType" NOT NULL, | ||
|
||
CONSTRAINT "Activity_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Folder" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"path" TEXT NOT NULL, | ||
"repository" "Repository" NOT NULL, | ||
|
||
CONSTRAINT "Folder_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "PermissionRule" ( | ||
"id" TEXT NOT NULL, | ||
"folderId" TEXT NOT NULL, | ||
"actionType" "ActionType" NOT NULL, | ||
|
||
CONSTRAINT "PermissionRule_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "File" ( | ||
"id" TEXT NOT NULL, | ||
"parentFolderId" INTEGER NOT NULL, | ||
"repository" "Repository" NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"url" TEXT NOT NULL, | ||
"sequence" INTEGER NOT NULL, | ||
"path" TEXT NOT NULL, | ||
|
||
CONSTRAINT "File_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Activity_userId_key" ON "Activity"("userId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Activity" ADD CONSTRAINT "Activity_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "PermissionRule" ADD CONSTRAINT "PermissionRule_folderId_fkey" FOREIGN KEY ("folderId") REFERENCES "Folder"("id") ON DELETE RESTRICT 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
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,94 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
// MODELS | ||
// Refrence https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#default | ||
|
||
// User | ||
|
||
model User { | ||
id String @id @default(uuid()) | ||
admin Boolean @default(false) | ||
activities Activity[] | ||
} | ||
|
||
// Activity | ||
|
||
model Activity { | ||
id String @id @default(uuid()) | ||
user User @relation(fields: [userId], references: [id]) | ||
userId String @unique | ||
activityType ActivityType | ||
actionableType ActionableType | ||
} | ||
|
||
|
||
// Folder | ||
|
||
model Folder { | ||
id String @id @default(uuid()) | ||
name String | ||
path String | ||
repository Repository | ||
permissions PermissionRule[] | ||
} | ||
|
||
// Permissions | ||
|
||
model PermissionRule { | ||
id String @id @default(uuid()) | ||
folder Folder @relation(fields: [folderId], references: [id]) | ||
folderId String | ||
actionType ActionType | ||
} | ||
|
||
enum ActionType { | ||
CREATE | ||
VIEW | ||
DELETE | ||
} | ||
|
||
// File | ||
|
||
model File { | ||
id String @id @default(uuid()) | ||
parentFolderId Int | ||
repository Repository | ||
name String | ||
url String | ||
sequence Int | ||
path String | ||
} | ||
|
||
// ENUMS | ||
|
||
// File, Folder | ||
enum Repository { | ||
VAULT | ||
EXHIBIT_SHARE | ||
} | ||
|
||
// Activity | ||
enum ActionableType { | ||
FILE | ||
FOLDER | ||
} | ||
|
||
// PermissionRule | ||
enum ActivityType { | ||
CREATED | ||
VIEWED | ||
DOWNLOADED | ||
MOVED | ||
DELETED | ||
RENAMED | ||
} |
Empty file.
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,15 @@ | ||
// lib/prisma.js | ||
import { PrismaClient } from '@prisma/client' | ||
|
||
let prisma | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
prisma = new PrismaClient() | ||
} else { | ||
if (!global.prisma) { | ||
global.prisma = new PrismaClient() | ||
} | ||
prisma = global.prisma | ||
} | ||
|
||
export default prisma |
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,20 @@ | ||
# BE | ||
# PORT | ||
PORT: 8080 | ||
|
||
# DATABASE | ||
# DATABASE_URL: mysql://root:password@localhost:3306/dev | ||
|
||
# TOKEN | ||
# SECRET_KEY: secretKey | ||
|
||
# LOG | ||
LOG_FORMAT: dev | ||
LOG_DIR: ../logs | ||
|
||
# CORS | ||
ORIGIN: "*" | ||
CREDENTIALS: true | ||
|
||
# DATABASE | ||
DATABASE_URL: your-database-url |
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 |
---|---|---|
|
@@ -1733,6 +1733,23 @@ | |
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.7.tgz#ccab5c8f7dc557a52ca3288c10075c9ccd37fff7" | ||
integrity sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw== | ||
|
||
"@prisma/client@^4.12.0": | ||
version "4.12.0" | ||
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-4.12.0.tgz#119b692888b1fe0fd3305c7d0e0ac48520aa6839" | ||
integrity sha512-j9/ighfWwux97J2dS15nqhl60tYoH8V0IuSsgZDb6bCFcQD3fXbXmxjYC8GHhIgOk3lB7Pq+8CwElz2MiDpsSg== | ||
dependencies: | ||
"@prisma/engines-version" "4.12.0-67.659ef412370fa3b41cd7bf6e94587c1dfb7f67e7" | ||
|
||
"@prisma/engines-version@4.12.0-67.659ef412370fa3b41cd7bf6e94587c1dfb7f67e7": | ||
version "4.12.0-67.659ef412370fa3b41cd7bf6e94587c1dfb7f67e7" | ||
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-4.12.0-67.659ef412370fa3b41cd7bf6e94587c1dfb7f67e7.tgz#51a1cc5c886564b542acde64a873645d0dee2566" | ||
integrity sha512-JIHNj5jlXb9mcaJwakM0vpgRYJIAurxTUqM0iX0tfEQA5XLZ9ONkIckkhuAKdAzocZ+80GYg7QSsfpjg7OxbOA== | ||
|
||
"@prisma/[email protected]": | ||
version "4.12.0" | ||
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.12.0.tgz#68d99078b70b2d9c339d0e8cbf2e99f00b72aa8c" | ||
integrity sha512-0alKtnxhNB5hYU+ymESBlGI4b9XrGGSdv7Ud+8TE/fBNOEhIud0XQsAR+TrvUZgS4na5czubiMsODw0TUrgkIA== | ||
|
||
"@sentry-internal/[email protected]": | ||
version "7.45.0" | ||
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.45.0.tgz#01f347d0d1b42451b340b32b12923dc22e042d27" | ||
|
@@ -7432,6 +7449,13 @@ pretty-format@^29.5.0: | |
ansi-styles "^5.0.0" | ||
react-is "^18.0.0" | ||
|
||
prisma@^4.12.0: | ||
version "4.12.0" | ||
resolved "https://registry.yarnpkg.com/prisma/-/prisma-4.12.0.tgz#1080eda951928cb3b0274ad29da9ae4f93143d68" | ||
integrity sha512-xqVper4mbwl32BWzLpdznHAYvYDWQQWK2tBfXjdUD397XaveRyAP7SkBZ6kFlIg8kKayF4hvuaVtYwXd9BodAg== | ||
dependencies: | ||
"@prisma/engines" "4.12.0" | ||
|
||
process-nextick-args@~2.0.0: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" | ||
|