Skip to content

Commit b385e43

Browse files
committed
node_prisma_api
0 parents  commit b385e43

File tree

28 files changed

+1666
-0
lines changed

28 files changed

+1666
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
# Keep environment variables out of version control
3+
.env

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["Prisma.prisma"]
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
port: 'PORT',
3+
4+
accessTokenPrivateKey: 'JWT_ACCESS_TOKEN_PRIVATE_KEY',
5+
accessTokenPublicKey: 'JWT_ACCESS_TOKEN_PUBLIC_KEY',
6+
refreshTokenPrivateKey: 'JWT_REFRESH_TOKEN_PRIVATE_KEY',
7+
refreshTokenPublicKey: 'JWT_REFRESH_TOKEN_PUBLIC_KEY',
8+
};

config/default.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
redisCacheExpiresIn: 60,
3+
refreshTokenExpiresIn: 60,
4+
accessTokenExpiresIn: 15,
5+
};

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '3'
2+
services:
3+
postgres:
4+
image: postgres:latest
5+
container_name: postgres
6+
ports:
7+
- '6500:5432'
8+
volumes:
9+
- progresDB:/data/postgres
10+
env_file:
11+
- ./.env
12+
13+
redis:
14+
image: redis:alpine
15+
container_name: redis
16+
ports:
17+
- '6379:6379'
18+
volumes:
19+
- redisDB:/data
20+
volumes:
21+
progresDB:
22+
redisDB:

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "node_prisma",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"start": "ts-node-dev --respawn --transpile-only --exit-child src/app.ts",
8+
"build": "tsc . -p"
9+
},
10+
"devDependencies": {
11+
"@types/bcryptjs": "^2.4.2",
12+
"@types/config": "^0.0.41",
13+
"@types/express": "^4.17.13",
14+
"@types/jsonwebtoken": "^8.5.8",
15+
"@types/lodash": "^4.14.182",
16+
"@types/node": "^17.0.31",
17+
"prisma": "^3.13.0",
18+
"typescript": "^4.6.4"
19+
},
20+
"dependencies": {
21+
"@prisma/client": "^3.13.0",
22+
"bcryptjs": "^2.4.3",
23+
"config": "^3.3.7",
24+
"dotenv": "^16.0.0",
25+
"envalid": "^7.3.1",
26+
"express": "^4.18.1",
27+
"jsonwebtoken": "^8.5.1",
28+
"lodash": "^4.17.21",
29+
"redis": "^4.1.0",
30+
"ts-node-dev": "^1.1.8",
31+
"zod": "^3.15.1"
32+
}
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- CreateEnum
2+
CREATE TYPE "RoleEnumType" AS ENUM ('user', 'admin');
3+
4+
-- CreateTable
5+
CREATE TABLE "users" (
6+
"id" TEXT NOT NULL DEFAULT E'uuid()',
7+
"name" VARCHAR(255) NOT NULL,
8+
"email" TEXT NOT NULL,
9+
"photo" TEXT NOT NULL DEFAULT E'default.png',
10+
"verified" BOOLEAN NOT NULL DEFAULT false,
11+
"verificationCode" TEXT,
12+
"password" TEXT NOT NULL,
13+
"passwordConfirm" TEXT NOT NULL,
14+
"role" "RoleEnumType" NOT NULL DEFAULT E'user',
15+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
16+
"updatedAt" TIMESTAMP(3) NOT NULL,
17+
18+
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
19+
);
20+
21+
-- CreateIndex
22+
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
23+
24+
-- CreateIndex
25+
CREATE INDEX "users_verificationCode_idx" ON "users"("verificationCode");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `verificationCode` on the `users` table. All the data in the column will be lost.
5+
6+
*/
7+
-- DropIndex
8+
DROP INDEX "users_verificationCode_idx";
9+
10+
-- AlterTable
11+
ALTER TABLE "users" DROP COLUMN "verificationCode";
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `passwordConfirm` on the `users` table. All the data in the column will be lost.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "users" DROP COLUMN "passwordConfirm",
9+
ALTER COLUMN "photo" DROP NOT NULL,
10+
ALTER COLUMN "verified" DROP NOT NULL,
11+
ALTER COLUMN "role" DROP NOT NULL;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "users" ALTER COLUMN "name" SET DATA TYPE TEXT;

0 commit comments

Comments
 (0)