feat: add admin router manager

This commit is contained in:
xion
2024-06-25 00:52:43 +08:00
parent f8777bd4ea
commit 3454e39ea4
18 changed files with 831 additions and 368 deletions

1
src/modules/index.ts Normal file
View File

@@ -0,0 +1 @@
export { sequelize } from './sequelize.ts';

26
src/modules/sequelize.ts Normal file
View File

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