Remove unnecessary description and whitespace from nexumi.mdc file
This commit is contained in:
25
apps/bot/Dockerfile
Normal file
25
apps/bot/Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
FROM node:22-alpine AS base
|
||||
WORKDIR /app
|
||||
RUN corepack enable
|
||||
|
||||
FROM base AS deps
|
||||
COPY package.json pnpm-workspace.yaml turbo.json tsconfig.base.json ./
|
||||
COPY apps/bot/package.json apps/bot/package.json
|
||||
COPY packages/shared/package.json packages/shared/package.json
|
||||
RUN pnpm install --frozen-lockfile=false
|
||||
|
||||
FROM deps AS build
|
||||
COPY . .
|
||||
RUN pnpm --filter @nexumi/shared build
|
||||
RUN pnpm --filter @nexumi/bot prisma:generate
|
||||
RUN pnpm --filter @nexumi/bot build
|
||||
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app
|
||||
RUN corepack enable
|
||||
COPY --from=build /app/node_modules ./node_modules
|
||||
COPY --from=build /app/apps/bot/dist ./apps/bot/dist
|
||||
COPY --from=build /app/apps/bot/prisma ./apps/bot/prisma
|
||||
COPY --from=build /app/packages/shared/dist ./packages/shared/dist
|
||||
COPY --from=build /app/apps/bot/package.json ./apps/bot/package.json
|
||||
CMD ["node", "apps/bot/dist/index.js"]
|
||||
29
apps/bot/package.json
Normal file
29
apps/bot/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@nexumi/bot",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"lint": "eslint src --ext .ts",
|
||||
"test": "vitest run",
|
||||
"typecheck": "tsc --noEmit -p tsconfig.json",
|
||||
"prisma:generate": "prisma generate",
|
||||
"prisma:migrate": "prisma migrate deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nexumi/shared": "workspace:*",
|
||||
"@prisma/client": "^5.22.0",
|
||||
"bullmq": "^5.34.0",
|
||||
"discord.js": "^14.17.3",
|
||||
"dotenv": "^16.4.7",
|
||||
"ioredis": "^5.4.2",
|
||||
"pino": "^9.6.0",
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prisma": "^5.22.0",
|
||||
"tsx": "^4.19.2"
|
||||
}
|
||||
}
|
||||
81
apps/bot/prisma/schema.prisma
Normal file
81
apps/bot/prisma/schema.prisma
Normal file
@@ -0,0 +1,81 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Guild {
|
||||
id String @id
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
settings GuildSettings?
|
||||
cases Case[]
|
||||
}
|
||||
|
||||
model GuildSettings {
|
||||
id String @id @default(cuid())
|
||||
guildId String @unique
|
||||
locale String @default("de")
|
||||
moderationEnabled Boolean @default(true)
|
||||
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id
|
||||
createdAt DateTime @default(now())
|
||||
warnings Warning[]
|
||||
notes ModNote[]
|
||||
}
|
||||
|
||||
model Case {
|
||||
id String @id @default(cuid())
|
||||
caseNumber Int
|
||||
guildId String
|
||||
targetUserId String
|
||||
moderatorId String
|
||||
action String
|
||||
reason String?
|
||||
metadata Json?
|
||||
deletedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
|
||||
warnings Warning[]
|
||||
moderationNote ModNote[]
|
||||
|
||||
@@unique([guildId, caseNumber])
|
||||
@@index([guildId, targetUserId])
|
||||
}
|
||||
|
||||
model Warning {
|
||||
id String @id @default(cuid())
|
||||
guildId String
|
||||
userId String
|
||||
moderatorId String
|
||||
reason String?
|
||||
caseId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
case Case? @relation(fields: [caseId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([guildId, userId])
|
||||
}
|
||||
|
||||
model ModNote {
|
||||
id String @id @default(cuid())
|
||||
guildId String
|
||||
userId String
|
||||
moderatorId String
|
||||
note String
|
||||
caseId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
case Case? @relation(fields: [caseId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([guildId, userId])
|
||||
}
|
||||
3
apps/bot/src/db.ts
Normal file
3
apps/bot/src/db.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export const prisma = new PrismaClient();
|
||||
17
apps/bot/src/env.ts
Normal file
17
apps/bot/src/env.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { config } from 'dotenv';
|
||||
import { z } from 'zod';
|
||||
|
||||
config();
|
||||
|
||||
const EnvSchema = z.object({
|
||||
NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
|
||||
BOT_TOKEN: z.string().min(1),
|
||||
BOT_CLIENT_ID: z.string().min(1),
|
||||
DATABASE_URL: z.string().url(),
|
||||
REDIS_URL: z.string().url(),
|
||||
LOG_LEVEL: z.string().default('info'),
|
||||
DEFAULT_LOCALE: z.enum(['de', 'en']).default('de'),
|
||||
BACKUP_RETENTION_DAYS: z.coerce.number().int().positive().default(14)
|
||||
});
|
||||
|
||||
export const env = EnvSchema.parse(process.env);
|
||||
6
apps/bot/src/logger.ts
Normal file
6
apps/bot/src/logger.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import pino from 'pino';
|
||||
import { env } from './env.js';
|
||||
|
||||
export const logger = pino({
|
||||
level: env.LOG_LEVEL
|
||||
});
|
||||
6
apps/bot/src/redis.ts
Normal file
6
apps/bot/src/redis.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import IORedis from 'ioredis';
|
||||
import { env } from './env.js';
|
||||
|
||||
export const redis = new IORedis(env.REDIS_URL, {
|
||||
maxRetriesPerRequest: null
|
||||
});
|
||||
8
apps/bot/tsconfig.json
Normal file
8
apps/bot/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src", "prisma"]
|
||||
}
|
||||
Reference in New Issue
Block a user