Configuration database with postgres
This commit is contained in:
parent
f2c57e5b3f
commit
fd5711503b
9 changed files with 1237 additions and 17 deletions
11
backend/.env
11
backend/.env
|
|
@ -1 +1,10 @@
|
|||
PORT=4000
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_HOST=175.15.15.90
|
||||
DB_PORT=5432
|
||||
DB_NAME=toptran
|
||||
|
||||
DATABASE_URL="postgresql://postgres:postgres@175.15.15.90:5432/toptran"
|
||||
|
||||
PORT=4000
|
||||
|
||||
|
|
|
|||
5
backend/.gitignore
vendored
Normal file
5
backend/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
node_modules
|
||||
# Keep environment variables out of version control
|
||||
.env
|
||||
|
||||
/src/generated/prisma
|
||||
1153
backend/package-lock.json
generated
1153
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -16,10 +16,13 @@
|
|||
"devDependencies": {
|
||||
"@types/cors": "^2.8.19",
|
||||
"@types/express": "^5.0.6",
|
||||
"@types/node": "^25.6.0",
|
||||
"prisma": "^7.8.0",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"tsx": "^4.21.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^7.8.0",
|
||||
"cors": "^2.8.6",
|
||||
"express": "^5.2.1"
|
||||
}
|
||||
|
|
|
|||
16
backend/prisma.config.ts
Normal file
16
backend/prisma.config.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// This file was generated by Prisma, and assumes you have installed the following:
|
||||
// npm install --save-dev prisma dotenv
|
||||
import "dotenv/config";
|
||||
import { defineConfig } from "prisma/config";
|
||||
|
||||
|
||||
export default defineConfig({
|
||||
schema: "prisma/schema.prisma",
|
||||
migrations: {
|
||||
path: "prisma/migrations",
|
||||
},
|
||||
datasource: {
|
||||
url: process.env.DATABASE_URL!,
|
||||
},
|
||||
|
||||
});
|
||||
32
backend/prisma/schema.prisma
Normal file
32
backend/prisma/schema.prisma
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
generator client {
|
||||
provider = "prisma-client"
|
||||
output = "../src/generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
}
|
||||
|
||||
model tokens {
|
||||
id String @id
|
||||
token String @unique
|
||||
type TokenType
|
||||
userId String
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
users users @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model users {
|
||||
id String @id
|
||||
name String
|
||||
email String @unique
|
||||
password String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime
|
||||
tokens tokens[]
|
||||
}
|
||||
|
||||
enum TokenType {
|
||||
REFRESH
|
||||
}
|
||||
|
|
@ -9,13 +9,11 @@ app.use(cors());
|
|||
app.get('/', (req, res) => {
|
||||
res.send('Hello World!');
|
||||
});
|
||||
|
||||
|
||||
app.get('/api/data', (req, res) => {
|
||||
res.json({ message: 'This is some data from the server!' });
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.listen(port, '0.0.0.0', () => {
|
||||
console.log(`Server is running on port ${port}`);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "nodenext",
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"target": "es2024",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"strict": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"isolatedModules": true,
|
||||
"skipLibCheck": true,
|
||||
}
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"types": ["node"],
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src"],
|
||||
}
|
||||
10
backend/tsconfig.tools.json
Normal file
10
backend/tsconfig.tools.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"types": ["node"],
|
||||
"strict": true
|
||||
},
|
||||
"include": ["prisma.config.ts"]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue