remove pino
This commit is contained in:
parent
aa4d2b5451
commit
c3b24ec29c
37
package.json
37
package.json
@ -38,16 +38,17 @@
|
|||||||
],
|
],
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kevisual/local-app-manager": "0.1.11-beta.2",
|
"@kevisual/local-app-manager": "0.1.17",
|
||||||
"@kevisual/router": "0.0.9",
|
"@kevisual/logger": "^0.0.1",
|
||||||
"@kevisual/use-config": "^1.0.10",
|
"@kevisual/router": "0.0.13",
|
||||||
|
"@kevisual/use-config": "^1.0.15",
|
||||||
"@types/semver": "^7.7.0",
|
"@types/semver": "^7.7.0",
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.5.0",
|
||||||
"formidable": "^3.5.2",
|
"formidable": "^3.5.4",
|
||||||
"ioredis": "^5.6.0",
|
"ioredis": "^5.6.1",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
@ -55,9 +56,7 @@
|
|||||||
"nanoid": "^5.1.5",
|
"nanoid": "^5.1.5",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"p-queue": "^8.1.0",
|
"p-queue": "^8.1.0",
|
||||||
"pg": "^8.14.1",
|
"pg": "^8.15.6",
|
||||||
"pino": "^9.6.0",
|
|
||||||
"pino-pretty": "^13.0.0",
|
|
||||||
"pm2": "^6.0.5",
|
"pm2": "^6.0.5",
|
||||||
"rollup-plugin-esbuild": "^6.2.1",
|
"rollup-plugin-esbuild": "^6.2.1",
|
||||||
"semver": "^7.7.1",
|
"semver": "^7.7.1",
|
||||||
@ -66,13 +65,13 @@
|
|||||||
"strip-ansi": "^7.1.0",
|
"strip-ansi": "^7.1.0",
|
||||||
"tar": "^7.4.3",
|
"tar": "^7.4.3",
|
||||||
"uuid": "^11.1.0",
|
"uuid": "^11.1.0",
|
||||||
"zod": "^3.24.2"
|
"zod": "^3.24.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kevisual/code-center-module": "workspace:*",
|
"@kevisual/code-center-module": "workspace:*",
|
||||||
"@kevisual/oss": "workspace:*",
|
"@kevisual/oss": "workspace:*",
|
||||||
"@kevisual/permission": "workspace:*",
|
"@kevisual/permission": "workspace:*",
|
||||||
"@kevisual/types": "^0.0.6",
|
"@kevisual/types": "^0.0.9",
|
||||||
"@rollup/plugin-alias": "^5.1.1",
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
"@rollup/plugin-commonjs": "^28.0.3",
|
"@rollup/plugin-commonjs": "^28.0.3",
|
||||||
"@rollup/plugin-json": "^6.1.0",
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
@ -84,20 +83,20 @@
|
|||||||
"@types/formidable": "^3.4.5",
|
"@types/formidable": "^3.4.5",
|
||||||
"@types/jsonwebtoken": "^9.0.9",
|
"@types/jsonwebtoken": "^9.0.9",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/node": "^22.13.14",
|
"@types/node": "^22.15.17",
|
||||||
"@types/react": "^19.0.12",
|
"@types/react": "^19.1.3",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"concurrently": "^9.1.2",
|
"concurrently": "^9.1.2",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"nodemon": "^3.1.9",
|
"nodemon": "^3.1.10",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"rollup": "^4.38.0",
|
"rollup": "^4.40.2",
|
||||||
"rollup-plugin-copy": "^3.5.0",
|
"rollup-plugin-copy": "^3.5.0",
|
||||||
"rollup-plugin-dts": "^6.2.1",
|
"rollup-plugin-dts": "^6.2.1",
|
||||||
"tape": "^5.9.0",
|
"tape": "^5.9.0",
|
||||||
"tsx": "^4.19.3",
|
"tsx": "^4.19.4",
|
||||||
"turbo": "^2.4.4",
|
"turbo": "^2.5.3",
|
||||||
"typescript": "^5.8.2"
|
"typescript": "^5.8.3"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"inflight": "latest",
|
"inflight": "latest",
|
||||||
@ -105,5 +104,5 @@
|
|||||||
"picomatch": "^4.0.2"
|
"picomatch": "^4.0.2"
|
||||||
},
|
},
|
||||||
"pnpm": {},
|
"pnpm": {},
|
||||||
"packageManager": "pnpm@10.7.0"
|
"packageManager": "pnpm@10.10.0"
|
||||||
}
|
}
|
1988
pnpm-lock.yaml
generated
1988
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,27 +1,10 @@
|
|||||||
import { pino } from 'pino';
|
|
||||||
import { useConfig } from '@kevisual/use-config/env';
|
import { useConfig } from '@kevisual/use-config/env';
|
||||||
|
import { Logger } from '@kevisual/logger';
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
|
|
||||||
export const logger = pino({
|
export const logger = new Logger({
|
||||||
level: config.LOG_LEVEL || 'info',
|
level: config.LOG_LEVEL || 'info',
|
||||||
transport: {
|
showTime: true,
|
||||||
target: 'pino-pretty',
|
|
||||||
options: {
|
|
||||||
colorize: true,
|
|
||||||
translateTime: 'SYS:standard',
|
|
||||||
ignore: 'pid,hostname',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
serializers: {
|
|
||||||
error: pino.stdSerializers.err,
|
|
||||||
req: pino.stdSerializers.req,
|
|
||||||
res: pino.stdSerializers.res,
|
|
||||||
},
|
|
||||||
base: {
|
|
||||||
app: 'code-center',
|
|
||||||
env: process.env.NODE_ENV || 'production',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const logError = (message: string, data?: any) => logger.error({ data }, message);
|
export const logError = (message: string, data?: any) => logger.error({ data }, message);
|
||||||
|
@ -9,6 +9,8 @@ import { User } from '@/models/user.ts';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { ConfigModel } from '@/routes/config/models/model.ts';
|
import { ConfigModel } from '@/routes/config/models/model.ts';
|
||||||
import { validateDirectory } from './util.ts';
|
import { validateDirectory } from './util.ts';
|
||||||
|
import { pick } from 'lodash-es';
|
||||||
|
import { getFileStat } from '@/routes/file/index.ts';
|
||||||
|
|
||||||
const cacheFilePath = useFileStore('cache-file', { needExists: true });
|
const cacheFilePath = useFileStore('cache-file', { needExists: true });
|
||||||
|
|
||||||
@ -16,6 +18,77 @@ router.get('/api/s1/resources/upload', async (req, res) => {
|
|||||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||||
res.end('Upload API is ready');
|
res.end('Upload API is ready');
|
||||||
});
|
});
|
||||||
|
export const parseIfJson = (data = '{}') => {
|
||||||
|
try {
|
||||||
|
const _data = JSON.parse(data);
|
||||||
|
if (typeof _data === 'object') return _data;
|
||||||
|
return {};
|
||||||
|
} catch (error) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
router.post('/api/s1/resources/upload/check', async (req, res) => {
|
||||||
|
const { tokenUser, token } = await checkAuth(req, res);
|
||||||
|
if (!tokenUser) {
|
||||||
|
res.end(error('Token is invalid.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('data', req.url);
|
||||||
|
const data = await router.getBody(req);
|
||||||
|
type Data = {
|
||||||
|
appKey: string;
|
||||||
|
version: string;
|
||||||
|
username: string;
|
||||||
|
directory: string;
|
||||||
|
files: { path: string; hash: string }[];
|
||||||
|
};
|
||||||
|
let { appKey, version, username, directory, files } = pick(data, ['appKey', 'version', 'username', 'directory', 'files']) as Data;
|
||||||
|
let uid = tokenUser.id;
|
||||||
|
if (username) {
|
||||||
|
const user = await User.getUserByToken(token);
|
||||||
|
const has = await user.hasUser(username, true);
|
||||||
|
if (!has) {
|
||||||
|
res.end(error('username is not found'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const _user = await User.findOne({ where: { username } });
|
||||||
|
uid = _user?.id || '';
|
||||||
|
}
|
||||||
|
if (!appKey || !version) {
|
||||||
|
res.end(error('appKey and version is required'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const { code, message } = validateDirectory(directory);
|
||||||
|
if (code !== 200) {
|
||||||
|
res.end(error(message));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
type CheckResult = {
|
||||||
|
path: string;
|
||||||
|
stat: any;
|
||||||
|
resourcePath: string;
|
||||||
|
hash: string;
|
||||||
|
uploadHash: string;
|
||||||
|
isUpload?: boolean;
|
||||||
|
};
|
||||||
|
const checkResult: CheckResult[] = [];
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
const file = files[i];
|
||||||
|
const relativePath = file.path;
|
||||||
|
const minioPath = `${username || tokenUser.username}/${appKey}/${version}${directory ? `/${directory}` : ''}/${relativePath}`;
|
||||||
|
let stat = await getFileStat(minioPath, true);
|
||||||
|
const statHash = stat?.etag || '';
|
||||||
|
checkResult.push({
|
||||||
|
path: relativePath,
|
||||||
|
uploadHash: file.hash,
|
||||||
|
resourcePath: minioPath,
|
||||||
|
isUpload: statHash === file.hash,
|
||||||
|
stat,
|
||||||
|
hash: statHash,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
res.end(JSON.stringify({ code: 200, data: checkResult }));
|
||||||
|
});
|
||||||
|
|
||||||
// /api/s1/resources/upload
|
// /api/s1/resources/upload
|
||||||
router.post('/api/s1/resources/upload', async (req, res) => {
|
router.post('/api/s1/resources/upload', async (req, res) => {
|
||||||
@ -26,6 +99,7 @@ router.post('/api/s1/resources/upload', async (req, res) => {
|
|||||||
}
|
}
|
||||||
const url = new URL(req.url || '', 'http://localhost');
|
const url = new URL(req.url || '', 'http://localhost');
|
||||||
const share = !!url.searchParams.get('public');
|
const share = !!url.searchParams.get('public');
|
||||||
|
const meta = parseIfJson(url.searchParams.get('meta'));
|
||||||
const noCheckAppFiles = !!url.searchParams.get('noCheckAppFiles');
|
const noCheckAppFiles = !!url.searchParams.get('noCheckAppFiles');
|
||||||
// 使用 formi dable 解析 multipart/form-data
|
// 使用 formi dable 解析 multipart/form-data
|
||||||
const form = new IncomingForm({
|
const form = new IncomingForm({
|
||||||
@ -106,6 +180,7 @@ router.post('/api/s1/resources/upload', async (req, res) => {
|
|||||||
if (share) {
|
if (share) {
|
||||||
metadata.share = 'public';
|
metadata.share = 'public';
|
||||||
}
|
}
|
||||||
|
Object.assign(metadata, meta);
|
||||||
await minioClient.fPutObject(bucketName, minioPath, tempPath, {
|
await minioClient.fPutObject(bucketName, minioPath, tempPath, {
|
||||||
'Content-Type': getContentType(relativePath),
|
'Content-Type': getContentType(relativePath),
|
||||||
'app-source': 'user-app',
|
'app-source': 'user-app',
|
||||||
|
@ -88,7 +88,7 @@ app
|
|||||||
}
|
}
|
||||||
const newApp = await app.update({ data: newData, ...rest });
|
const newApp = await app.update({ data: newData, ...rest });
|
||||||
ctx.body = newApp;
|
ctx.body = newApp;
|
||||||
if (app.status !== 'running') {
|
if (app.status !== 'running' || data?.share || rest?.status) {
|
||||||
setExpire(newApp.key, app.user);
|
setExpire(newApp.key, app.user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { minioClient } from '../../../modules/minio.ts';
|
import { minioClient } from '../../../modules/minio.ts';
|
||||||
import { bucketName } from '../../../modules/minio.ts';
|
import { bucketName } from '../../../modules/minio.ts';
|
||||||
import { CopyDestinationOptions, CopySourceOptions } from 'minio';
|
import { BucketItemStat, CopyDestinationOptions, CopySourceOptions } from 'minio';
|
||||||
type MinioListOpt = {
|
type MinioListOpt = {
|
||||||
prefix: string;
|
prefix: string;
|
||||||
recursive?: boolean;
|
recursive?: boolean;
|
||||||
@ -43,7 +43,7 @@ export const getMinioList = async <IS_FILE extends boolean>(opts: MinioListOpt):
|
|||||||
});
|
});
|
||||||
return res as IS_FILE extends true ? MinioFile[] : MinioDirectory[];
|
return res as IS_FILE extends true ? MinioFile[] : MinioDirectory[];
|
||||||
};
|
};
|
||||||
export const getFileStat = async (prefix: string, isFile?: boolean): Promise<any> => {
|
export const getFileStat = async (prefix: string, isFile?: boolean): Promise<BucketItemStat | null> => {
|
||||||
try {
|
try {
|
||||||
const obj = await minioClient.statObject(bucketName, prefix);
|
const obj = await minioClient.statObject(bucketName, prefix);
|
||||||
if (isFile && obj.size === 0) {
|
if (isFile && obj.size === 0) {
|
||||||
@ -174,7 +174,8 @@ export const mvUserAToUserB = async (usernameA: string, usernameB: string, clear
|
|||||||
const source = new CopySourceOptions({ Bucket: bucketName, Object: item.name });
|
const source = new CopySourceOptions({ Bucket: bucketName, Object: item.name });
|
||||||
const stat = await getFileStat(item.name);
|
const stat = await getFileStat(item.name);
|
||||||
const newName = item.name.slice(oldPrefix.length);
|
const newName = item.name.slice(oldPrefix.length);
|
||||||
const metadata = stat?.userMetadata;
|
// @ts-ignore
|
||||||
|
const metadata = stat?.userMetadata || stat.metaData;
|
||||||
const destination = new CopyDestinationOptions({
|
const destination = new CopyDestinationOptions({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Object: `${newPrefix}${newName}`,
|
Object: `${newPrefix}${newName}`,
|
||||||
|
@ -9,6 +9,7 @@ export type MarkData = {
|
|||||||
mdList?: string[]; // markdown list
|
mdList?: string[]; // markdown list
|
||||||
type?: string; // 类型 markdown | json | html | image | video | audio | code | link | file
|
type?: string; // 类型 markdown | json | html | image | video | audio | code | link | file
|
||||||
data?: any;
|
data?: any;
|
||||||
|
key?: string; // 文件的名称, 唯一
|
||||||
push?: boolean; // 是否推送到elasticsearch
|
push?: boolean; // 是否推送到elasticsearch
|
||||||
pushTime?: Date; // 推送时间
|
pushTime?: Date; // 推送时间
|
||||||
summary?: string; // 摘要
|
summary?: string; // 摘要
|
||||||
@ -47,7 +48,7 @@ export class MarkModel extends Model {
|
|||||||
declare description: string; // 描述,可以ai生成
|
declare description: string; // 描述,可以ai生成
|
||||||
declare cover: string; // 封面,可以ai生成
|
declare cover: string; // 封面,可以ai生成
|
||||||
declare thumbnail: string; // 缩略图
|
declare thumbnail: string; // 缩略图
|
||||||
|
declare key: string; // 文件路径
|
||||||
declare markType: string; // markdown | json | html | image | video | audio | code | link | file
|
declare markType: string; // markdown | json | html | image | video | audio | code | link | file
|
||||||
declare link: string; // 访问链接
|
declare link: string; // 访问链接
|
||||||
declare tags: string[]; // 标签
|
declare tags: string[]; // 标签
|
||||||
@ -231,6 +232,10 @@ export const MarkMInit = async <T = any>(opts: MarkInitOpts<T>, sync?: Opts) =>
|
|||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
},
|
},
|
||||||
|
key: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
defaultValue: '',
|
||||||
|
},
|
||||||
markType: {
|
markType: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
defaultValue: 'md', // markdown | json | html | image | video | audio | code | link | file
|
defaultValue: 'md', // markdown | json | html | image | video | audio | code | link | file
|
||||||
@ -316,4 +321,4 @@ export const syncMarkModel = async (sync?: Opts) => {
|
|||||||
await MarkMInit({ sequelize, tableName: 'micro_mark' }, sync);
|
await MarkMInit({ sequelize, tableName: 'micro_mark' }, sync);
|
||||||
};
|
};
|
||||||
|
|
||||||
syncMarkModel({ sync: true, alter: true, logging: false });
|
syncMarkModel({ sync: true, alter: true, logging: false });
|
||||||
|
@ -38,7 +38,7 @@ export const changeRootPassword = async () => {
|
|||||||
});
|
});
|
||||||
const user = await User.findOne({ where: { username: 'root' } });
|
const user = await User.findOne({ where: { username: 'root' } });
|
||||||
if (user) {
|
if (user) {
|
||||||
await user.createPassword('123456');
|
await user.createPassword('Abear123456x');
|
||||||
await user.save();
|
await user.save();
|
||||||
console.log('change root password done');
|
console.log('change root password done');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 6309a577f73fd27ab284270f56a7f83c5d8e4569
|
Subproject commit 460f80657c8b8adc93dd34f41c3eec1704f86c46
|
Loading…
x
Reference in New Issue
Block a user