This commit is contained in:
熊潇 2025-07-04 00:02:18 +08:00
parent c7ddaf88f6
commit b3993f654c
4 changed files with 28 additions and 3 deletions

20
src/modules/logger.ts Normal file
View File

@ -0,0 +1,20 @@
import { useConfig } from '@kevisual/use-config/env';
import { Logger } from '@kevisual/logger';
const config = useConfig();
export const logger = new Logger({
level: config.LOG_LEVEL || 'info',
showTime: true,
});
export const logError = (message: string, data?: any) => logger.error({ data }, message);
export const logWarning = (message: string, data?: any) => logger.warn({ data }, message);
export const logInfo = (message: string, data?: any) => logger.info({ data }, message);
export const logDebug = (message: string, data?: any) => logger.debug({ data }, message);
export const log = {
error: logError,
warn: logWarning,
info: logInfo,
debug: logDebug,
};

View File

@ -1,5 +1,6 @@
import { Client, ClientOptions } from 'minio';
import { config } from './config.ts';
import { OssBase } from '@kevisual/oss/services';
const minioConfig = {
endPoint: config.MINIO_ENDPOINT || 'localhost',
port: parseInt(config.MINIO_PORT || '9000'),
@ -24,3 +25,9 @@ if (!minioClient) {
// const res = await minioClient.putObject(bucketName, 'root/test/0.0.1/a.txt', 'test');
// console.log('minio putObject', res);
})();
export const oss = new OssBase({
client: minioClient,
bucketName: bucketName,
prefix: '',
});

View File

@ -1,6 +1,6 @@
import { Sequelize } from 'sequelize';
import { config } from './config.ts';
import { log } from '../logger/index.ts';
import { log } from './logger.ts';
export type PostgresConfig = {
postgres: {
username: string;

View File

@ -2,8 +2,6 @@ import './routes/index.ts';
import { app } from './app.ts';
import type { App } from '@kevisual/router';
import { User } from './models/user.ts';
// import { addAuth } from '@kevisual/code-center-module/models';
// addAuth(app);
import { createCookie, getSomeInfoFromReq } from './routes/user/me.ts';
/**