This commit is contained in:
2026-02-02 07:13:26 -06:00
parent b6f78e4659
commit e37c64fb1d
6 changed files with 2240 additions and 7 deletions

12
drizzle.config.js Normal file
View File

@@ -0,0 +1,12 @@
import {defineConfig} from 'drizzle-kit'
if(!process.env.DATABASE_URL){
throw new Error('DATABASE_URL is not defined')
}
export default defineConfig({
dialect:'postgresql',
schema: "./src/db/schema",
out: './migrations',
dbCredentials: {url: process.env.DATABASE_URL}
})

2199
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,8 +5,8 @@
"main": "index.js",
"type": "module",
"scripts": {
"dev": "node --watch src/index.js",
"start": "node src/index.js"
"dev": "dotenvx run -f .env -- node --watch src/index.js",
"start": "dotenvx run -f .env -- node src/index.js"
},
"repository": {
"type": "git",
@@ -16,11 +16,18 @@
"author": "",
"license": "ISC",
"dependencies": {
"@dotenvx/dotenvx": "^1.52.0",
"drizzle-orm": "^0.45.1",
"express": "^5.2.1",
"pg": "^8.18.0",
"wscat": "^6.1.0"
},
"devDependencies": {
"@types/node": "^25.1.0",
"@types/ws": "^8.18.1"
"@types/pg": "^8.16.0",
"@types/ws": "^8.18.1",
"drizzle-kit": "^0.31.8",
"tsx": "^4.21.0",
"typescript": "^5.9.3"
}
}

12
src/db/db.js Normal file
View File

@@ -0,0 +1,12 @@
import { drizzle } from "drizzle-orm/node-postgres";
import pg from 'pg'
if(!process.env.DATABASE_URL){
throw new Error('DATABASE_URL is not defined')
}
export const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL
})
export const db = drizzle(pool)

9
src/db/schema/matches.js Normal file
View File

@@ -0,0 +1,9 @@
import { pgEnum, serial } from "drizzle-orm/pg-core";
export const matchStatusEnum = pgEnum('match_status',['scheduled','live', 'finished'])
export const matches = pgTable('matches', {
id: serial('id').primaryKey(),
sport: text('sport').noNull(),
homeTeam: text('home_team').notNull()
})

View File

@@ -2,7 +2,7 @@ import express from 'express'
const app = express()
const port = 8081
const port = process.env.PORT || 8081
app.use(express.json())