feat: add bot and api services with config, logger and database packages
- Add bot service with telegram integration and webhook/polling modes - Add api service with hono, swagger and zod-openapi - Create config package for environment variable management - Create logger package for colored console logging - Create database package with prisma integration - Remove next.js web and docs apps - Update turbo.json for new services - Add dockerfiles and gitea workflows for deployment
This commit is contained in:
1
packages/database/.env.example
Normal file
1
packages/database/.env.example
Normal file
@@ -0,0 +1 @@
|
||||
DATABASE_URL="your-database-url"
|
||||
5
packages/database/.gitignore
vendored
Normal file
5
packages/database/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
# Keep environment variables out of version control
|
||||
.env
|
||||
|
||||
/generated/prisma
|
||||
19
packages/database/package.json
Normal file
19
packages/database/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@repo/db",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"db:generate": "prisma generate",
|
||||
"db:migrate": "prisma migrate dev --skip-generate",
|
||||
"db:deploy": "prisma migrate deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^6.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.0.10",
|
||||
"prisma": "^6.11.1"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
}
|
||||
30
packages/database/prisma/schema.prisma
Normal file
30
packages/database/prisma/schema.prisma
Normal file
@@ -0,0 +1,30 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model TelegramSession {
|
||||
id String @id
|
||||
data Json
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model TelegramUser {
|
||||
id String @id
|
||||
username String?
|
||||
isBlocked Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
8
packages/database/src/client.ts
Normal file
8
packages/database/src/client.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { PrismaClient } from "../generated/prisma";
|
||||
|
||||
const globalForPrisma = global as unknown as { prisma: PrismaClient };
|
||||
|
||||
export const prisma =
|
||||
globalForPrisma.prisma || new PrismaClient()
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|
||||
2
packages/database/src/index.ts
Normal file
2
packages/database/src/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { prisma } from "./client"; // exports instance of prisma
|
||||
export * from "../generated/prisma"; // exports generated types from prisma
|
||||
Reference in New Issue
Block a user