feat: add snippet and test for supa db

This commit is contained in:
2024-10-21 01:31:58 +08:00
parent 089f629096
commit 0eae9458c6
8 changed files with 177 additions and 40 deletions

View File

@@ -0,0 +1,26 @@
import { useConfig } from '@abearxiong/use-config';
import { Sequelize } from 'sequelize';
type PostgresConfig = {
supabaseSQL: {
username: string;
password: string;
host: string;
port: number;
database: string;
};
};
const config = useConfig<PostgresConfig>();
const postgresConfig = config.supabaseSQL;
if (!postgresConfig) {
console.error('postgres config is required');
process.exit(1);
}
// connect to db
export const sequelize = new Sequelize({
dialect: 'postgres',
...postgresConfig,
// logging: false,
});