Adds Drizzle ORM with Infisical for secure database management

Integrates Drizzle ORM to provide a type-safe and modern solution for PostgreSQL database interactions. Establishes Infisical as the central secret management system, ensuring sensitive database credentials and other environment variables are securely loaded dynamically based on the active environment.

Includes a PowerShell script to standardize environment setup for Drizzle CLI operations, fetching secrets from Infisical and local configuration files. New npm scripts `drizzle:push` and `drizzle:pull` are added to streamline database schema migrations.

Sets up an initial database module with a `DatabaseService` and a sample `users` schema to demonstrate Drizzle's functionality and integration with Infisical secrets.
This commit is contained in:
dahyeon committed 2025-11-09 16:05:18 +00:00
1 parent 6aec3e91b8
commit 469e799b01
13 files changed
+1651 -4

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { InfisicalSDK } from "@infisical/sdk";
const INFISICAL_SITE_URL = "https://secret-manager.dahyeon.us/"
const INFISICAL_CLIENT_SECRET = process.env.INFISICAL_CLIENT_SECRET;
const INFISICAL_CLIENT_ID = process.env.INFISICAL_CLIENT_ID;
const INFISICAL_PROJECT_ID = process.env.INFISICAL_PROJECT_ID;
if (!INFISICAL_CLIENT_SECRET || !INFISICAL_CLIENT_ID || !INFISICAL_PROJECT_ID) {
console.error("Missing infisical environment variables");
process.exit(1);
}
const infisicalClient = new InfisicalSDK({ siteUrl: INFISICAL_SITE_URL })
await infisicalClient.auth().universalAuth.login({
clientId: INFISICAL_CLIENT_ID,
clientSecret: INFISICAL_CLIENT_SECRET,
});
const res = await infisicalClient.secrets().listSecrets({
environment: process.env.NODE_ENV === 'prod' ? 'prod' : process.env.NODE_ENV === 'test' ? 'staging' : 'dev',
projectId: INFISICAL_PROJECT_ID,
});
// Output as environment variable format for PowerShell to consume
for (const s of res.secrets) {
console.log(`${s.secretKey}=${s.secretValue}`);
}