Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added assets API and fixed user model #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
V18.17.1
21 changes: 6 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"license": "ISC",
"dependencies": {
"@prisma/client": "^5.7.0",
"@types/bcrypt": "^5.0.2",
"@types/express": "^4.17.21",
"@types/joi": "^17.2.3",
"@types/node": "^20.10.0",
Expand All @@ -38,24 +37,24 @@
},
"devDependencies": {
"@prisma/migrate": "^5.7.0",
"@types/nodemailer": "^6.4.14",
"@types/passport": "^1.0.16",
"@types/passport-jwt": "^3.0.13",
"@types/bcryptjs": "^2.4.6",
"@types/compression": "^1.7.5",
"@types/cors": "^2.8.17",
"@types/morgan": "^1.9.9",
"@types/nodemailer": "^6.4.14",
"@types/passport": "^1.0.16",
"@types/passport-jwt": "^3.0.13",
"@types/xss-filters": "^0.0.30",
"dotenv": "^16.3.1",
"nodemon": "^3.0.1",
"prisma": "^5.7.0",
"typescript": "^5.3.2",
"joi": "^17.11.0",
"jsonwebtoken": "^9.0.2",
"nodemailer": "^6.9.7",
"nodemon": "^3.0.1",
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"pg": "^8.11.3",
"ts-node": "^10.9.1"
"prisma": "^5.7.0",
"ts-node": "^10.9.1",
"typescript": "^5.3.2"
}
}
42 changes: 0 additions & 42 deletions prisma/migrations/20231213132332_updated/migration.sql

This file was deleted.

18 changes: 0 additions & 18 deletions prisma/migrations/20231213150650_clear/migration.sql

This file was deleted.

184 changes: 184 additions & 0 deletions prisma/migrations/20231228135037_1/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
-- CreateEnum
CREATE TYPE "TokenType" AS ENUM ('ACCESS', 'RESET_PASSWORD');

-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"names" TEXT NOT NULL,
"phone" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"is_line_manager" BOOLEAN NOT NULL,
"occupation_address_id" INTEGER NOT NULL,
"report_to" TEXT,
"role_id" INTEGER NOT NULL,
"custom_access" TEXT[],

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Role" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"access" TEXT[],

CONSTRAINT "Role_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "OccupationAddress" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"type" TEXT NOT NULL,
"parent_id" INTEGER,

CONSTRAINT "OccupationAddress_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Location" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"status" TEXT NOT NULL,
"building_id" TEXT NOT NULL,
"room_id" TEXT NOT NULL,

CONSTRAINT "Location_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Building" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "Building_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Room" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "Room_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ResetPasswordTokens" (
"id" SERIAL NOT NULL,
"token" TEXT NOT NULL,
"tokenUserEmail" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "ResetPasswordTokens_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Token" (
"id" SERIAL NOT NULL,
"token" TEXT NOT NULL,
"type" "TokenType" NOT NULL,
"expires" TIMESTAMP(3) NOT NULL,
"blacklisted" BOOLEAN NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT NOT NULL,

CONSTRAINT "Token_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Asset" (
"asset_id" TEXT NOT NULL,
"category_id" TEXT NOT NULL,
"brand_id" TEXT NOT NULL,
"stock_id" TEXT NOT NULL,
"supplier_id" TEXT NOT NULL,
"purchase_order_number" TEXT NOT NULL,
"value" DOUBLE PRECISION NOT NULL,
"life_span_years" INTEGER NOT NULL,
"date_in" TEXT NOT NULL,

CONSTRAINT "Asset_pkey" PRIMARY KEY ("asset_id")
);

-- CreateTable
CREATE TABLE "AssetCategory" (
"asset_category_id" TEXT NOT NULL,
"category_name" TEXT NOT NULL,

CONSTRAINT "AssetCategory_pkey" PRIMARY KEY ("asset_category_id")
);

-- CreateTable
CREATE TABLE "Specification" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"values" TEXT[],
"category_id" TEXT NOT NULL,

CONSTRAINT "Specification_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Stock" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "Stock_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Brand" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "Brand_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Supplier" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "Supplier_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "ResetPasswordTokens_tokenUserEmail_key" ON "ResetPasswordTokens"("tokenUserEmail");

-- AddForeignKey
ALTER TABLE "User" ADD CONSTRAINT "User_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "Role"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "User" ADD CONSTRAINT "User_occupation_address_id_fkey" FOREIGN KEY ("occupation_address_id") REFERENCES "OccupationAddress"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Location" ADD CONSTRAINT "Location_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Location" ADD CONSTRAINT "Location_building_id_fkey" FOREIGN KEY ("building_id") REFERENCES "Building"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Location" ADD CONSTRAINT "Location_room_id_fkey" FOREIGN KEY ("room_id") REFERENCES "Room"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Token" ADD CONSTRAINT "Token_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Asset" ADD CONSTRAINT "Asset_brand_id_fkey" FOREIGN KEY ("brand_id") REFERENCES "Brand"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Asset" ADD CONSTRAINT "Asset_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "AssetCategory"("asset_category_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Asset" ADD CONSTRAINT "Asset_stock_id_fkey" FOREIGN KEY ("stock_id") REFERENCES "Stock"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Asset" ADD CONSTRAINT "Asset_supplier_id_fkey" FOREIGN KEY ("supplier_id") REFERENCES "Supplier"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Specification" ADD CONSTRAINT "Specification_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "AssetCategory"("asset_category_id") ON DELETE RESTRICT ON UPDATE CASCADE;
Loading