Compare commits

4 Commits

Author SHA1 Message Date
hikari 7997c9f59d feat: set up Discord bot scaffolding
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 48s
- Add Rondelle interface with discord client and database
- Add logger utility using @nhcarrigan/logger
- Add database utility for Prisma client instantiation
- Update index.ts with bot startup logic
- Update .gitignore to exclude prod/ build output
2026-01-21 20:23:32 -08:00
hikari ce59bf47f9 feat: add Prisma schema for pairing history
Add MongoDB schema with Prisma 6.8.2 for tracking:
- ServerEvent: events per server (coffee chats, study groups, etc.)
- UserPairingHistory: user pairing records per server
- PairingRecord: individual pairing entries with event context

This enables smart grouping that avoids recent pairings per-event.
2026-01-21 17:56:28 -08:00
naomi 5003386577 chore: fix up the scaffolding 2026-01-21 16:08:44 -08:00
hikari 2352f45794 feat: scaffold TypeScript project
- Initialize pnpm project with TypeScript support
- Add standard ESLint and TypeScript configurations
- Create basic src/index.ts with sample export
- Set up GitHub Actions CI workflow
- Add prod.env with 1Password references
- Configure .gitignore for Node.js projects

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
2026-01-21 13:59:28 -08:00
13 changed files with 4613 additions and 13 deletions
+40
View File
@@ -0,0 +1,40 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check dependency pinning
uses: naomi-lgbt/dependency-pin-check@main
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run linter
run: pnpm lint
- name: Build project
run: pnpm build
- name: Run tests
run: pnpm test
+2
View File
@@ -0,0 +1,2 @@
node_modules
prod
+3 -13
View File
@@ -1,16 +1,6 @@
# New Repository Template
# Rondelle
This template contains all of our basic files for a new GitHub repository. There is also a handy workflow that will create an issue on a new repository made from this template, with a checklist for the steps we usually take in setting up a new repository.
If you're starting a Node.JS project with TypeScript, we have a [specific template](https://github.com/naomi-lgbt/nodejs-typescript-template) for that purpose.
## Readme
Delete all of the above text (including this line), and uncomment the below text to use our standard readme template.
<!-- # Project Name
Project Description
A Discord bot to facilitate coffee chats or breakouts.
## Live Version
@@ -36,4 +26,4 @@ Copyright held by Naomi Carrigan.
## Contact
We may be contacted through our [Chat Server](http://chat.nhcarrigan.com) or via email at `contact@nhcarrigan.com`. -->
We may be contacted through our [Chat Server](http://chat.nhcarrigan.com) or via email at `contact@nhcarrigan.com`.
+5
View File
@@ -0,0 +1,5 @@
import NaomisConfig from "@nhcarrigan/eslint-config";
export default [
...NaomisConfig,
];
+35
View File
@@ -0,0 +1,35 @@
{
"name": "rondelle",
"pnpm": {
"onlyBuiltDependencies": [
"@prisma/engines",
"esbuild",
"prisma"
]
},
"version": "0.0.0",
"description": "",
"main": "./prod/index.js",
"scripts": {
"build": "tsc",
"start": "op run --env-file=prod.env -- node prod/index.js",
"lint": "eslint src --max-warnings 0",
"test": "echo \"No tests yet\" && exit 0"
},
"keywords": [],
"author": "Naomi Carrigan <contact@nhcarrigan.com>",
"license": "See LICENSE.md",
"type": "module",
"devDependencies": {
"@nhcarrigan/eslint-config": "5.2.0",
"@nhcarrigan/typescript-config": "4.0.0",
"@types/node": "22.10.6",
"prisma": "6.8.2",
"typescript": "5.7.3"
},
"dependencies": {
"@nhcarrigan/logger": "1.1.1",
"@prisma/client": "6.8.2",
"discord.js": "14.25.1"
}
}
+4397
View File
File diff suppressed because it is too large Load Diff
+35
View File
@@ -0,0 +1,35 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = env("MONGO_URI")
}
model ServerEvent {
id String @id @default(auto()) @map("_id") @db.ObjectId
serverId String
eventId String
eventName String
createdAt DateTime @default(now())
createdBy String
@@unique([serverId, eventId])
@@index([serverId])
}
model UserPairingHistory {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String
serverId String
pairings PairingRecord[]
@@unique([userId, serverId])
}
type PairingRecord {
recipientId String
eventId String
sessionDate DateTime
}
+7
View File
@@ -0,0 +1,7 @@
# 1Password vault references - safe to commit
# Run with: op run --env-file=prod.env -- <command>
# Example environment variables
DATABASE_URL=op://Development/rondelle-database/connection-string
API_KEY=op://Development/rondelle-api/api-key
SECRET_TOKEN=op://Development/rondelle-secrets/token
+34
View File
@@ -0,0 +1,34 @@
/**
* @copyright 2026
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { Client, GatewayIntentBits } from "discord.js";
import { instantiatePrisma } from "./utils/database.js";
import { logger } from "./utils/logger.js";
import type { Rondelle } from "./interfaces/rondelle.js";
/**
* Starts the Discord bot and connects to the database.
*/
const startBot = async(): Promise<void> => {
const rondelle: Rondelle = {
database: await instantiatePrisma(),
discord: new Client({
intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates ],
}),
};
rondelle.discord.once("ready", () => {
void logger.log("info", `Logged in as ${rondelle.discord.user?.tag ?? "unknown"}`);
});
await rondelle.discord.login(process.env.DISCORD_TOKEN);
};
await startBot().catch(async(error: unknown) => {
const actualError = error instanceof Error
? error
: new Error(String(error));
await logger.error("startBot", actualError);
});
+14
View File
@@ -0,0 +1,14 @@
/**
* @copyright 2026
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import type { PrismaClient } from "@prisma/client";
import type { Client } from "discord.js";
interface Rondelle {
database: PrismaClient;
discord: Client;
}
export type { Rondelle };
+20
View File
@@ -0,0 +1,20 @@
/**
* @copyright 2026
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { PrismaClient } from "@prisma/client";
import { logger } from "./logger.js";
/**
* Creates and connects a Prisma client instance.
* @returns The connected Prisma client.
*/
const instantiatePrisma = async(): Promise<PrismaClient> => {
const client = new PrismaClient();
await client.$connect();
await logger.log("info", "Connected to database.");
return client;
};
export { instantiatePrisma };
+13
View File
@@ -0,0 +1,13 @@
/**
* @copyright 2026
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { Logger } from "@nhcarrigan/logger";
const logger = new Logger(
"rondelle",
process.env.LOG_TOKEN ?? "",
);
export { logger };
+8
View File
@@ -0,0 +1,8 @@
{
"extends": "@nhcarrigan/typescript-config",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./prod",
},
"include": ["src/**/*"]
}