mirror of
https://github.com/crystelf/crystelf-core.git
synced 2025-07-04 06:39:18 +00:00
重构项目,模块化项目
This commit is contained in:
parent
20a932fd47
commit
42ee17a1ff
@ -2,11 +2,11 @@ import express from 'express';
|
||||
import compression from 'compression';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import logger from './utils/core/logger';
|
||||
import paths from './utils/core/path';
|
||||
import config from './utils/core/config';
|
||||
import logger from './utils/system/logger';
|
||||
import paths from './utils/system/path';
|
||||
import config from './utils/system/config';
|
||||
import './services/ws/wsServer';
|
||||
import System from './utils/core/system';
|
||||
import System from './utils/system/system';
|
||||
|
||||
const apps = {
|
||||
async createApp() {
|
@ -1,7 +1,7 @@
|
||||
import Redis from 'ioredis';
|
||||
import logger from '../../utils/core/logger';
|
||||
import tools from '../../utils/core/tool';
|
||||
import config from '../../utils/core/config';
|
||||
import logger from '../../utils/system/logger';
|
||||
import tools from '../../utils/system/tool';
|
||||
import config from '../../utils/system/config';
|
||||
import redisTools from '../../utils/redis/redisTools';
|
||||
import Persistence from '../../utils/redis/persistence';
|
||||
import IUser from '../../types/user';
|
@ -1,7 +1,7 @@
|
||||
import { AuthenticatedSocket } from '../../types/ws';
|
||||
import wsTools from '../../utils/ws/wsTools';
|
||||
import { WebSocket } from 'ws';
|
||||
import logger from '../../utils/core/logger';
|
||||
import logger from '../../utils/system/logger';
|
||||
import redisService from '../redis/redis';
|
||||
import wsClientManager from './wsClientManager';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import WebSocket, { WebSocketServer } from 'ws';
|
||||
import config from '../../utils/core/config';
|
||||
import logger from '../../utils/core/logger';
|
||||
import config from '../../utils/system/config';
|
||||
import logger from '../../utils/system/logger';
|
||||
import { AuthenticatedSocket, AuthMessage, WSMessage } from '../../types/ws';
|
||||
import WsTools from '../../utils/ws/wsTools';
|
||||
import wsHandler from './handler';
|
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import response from '../core/response';
|
||||
import Config from '../core/config';
|
||||
import response from '../system/response';
|
||||
import Config from '../system/config';
|
||||
|
||||
let tools = {
|
||||
/**
|
@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import paths from '../core/path';
|
||||
import fc from '../core/file';
|
||||
import logger from '../core/logger';
|
||||
import paths from '../system/path';
|
||||
import fc from '../system/file';
|
||||
import logger from '../system/logger';
|
||||
import fs from 'fs/promises';
|
||||
|
||||
class Persistence {
|
@ -1,4 +1,4 @@
|
||||
import logger from '../core/logger';
|
||||
import logger from '../system/logger';
|
||||
|
||||
class redisTools {
|
||||
public static serialize<T>(data: T): string {
|
@ -1,5 +1,5 @@
|
||||
import WebSocket from 'ws';
|
||||
import logger from '../core/logger';
|
||||
import logger from '../system/logger';
|
||||
import { setInterval } from 'node:timers';
|
||||
|
||||
class WsTools {
|
12
src/main.ts
12
src/main.ts
@ -1,9 +1,9 @@
|
||||
import apps from './app';
|
||||
import logger from './utils/core/logger';
|
||||
import config from './utils/core/config';
|
||||
import redis from './services/redis/redis';
|
||||
import autoUpdater from './utils/core/autoUpdater';
|
||||
import System from './utils/core/system';
|
||||
import apps from './core/app';
|
||||
import logger from './core/utils/system/logger';
|
||||
import config from './core/utils/system/config';
|
||||
import redis from './core/services/redis/redis';
|
||||
import autoUpdater from './core/utils/system/autoUpdater';
|
||||
import System from './core/utils/system/system';
|
||||
|
||||
config.check(['PORT', 'DEBUG', 'RD_PORT', 'RD_ADD', 'WS_SECRET', 'WS_PORT']);
|
||||
const PORT = config.get('PORT') || 3000;
|
||||
|
@ -1,9 +1,9 @@
|
||||
import express from 'express';
|
||||
import response from '../../utils/core/response';
|
||||
import response from '../../core/utils/system/response';
|
||||
import BotService from './bot.service';
|
||||
import tools from '../../utils/modules/tools';
|
||||
import logger from '../../utils/core/logger';
|
||||
import wsClientManager from '../../services/ws/wsClientManager';
|
||||
import tools from '../../core/utils/modules/tools';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
import wsClientManager from '../../core/services/ws/wsClientManager';
|
||||
|
||||
class BotController {
|
||||
private readonly router: express.Router;
|
||||
|
@ -1,10 +1,10 @@
|
||||
import logger from '../../utils/core/logger';
|
||||
import paths from '../../utils/core/path';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
import paths from '../../core/utils/system/path';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import redisService from '../../services/redis/redis';
|
||||
import wsClientManager from '../../services/ws/wsClientManager';
|
||||
import tools from '../../utils/core/tool';
|
||||
import redisService from '../../core/services/redis/redis';
|
||||
import wsClientManager from '../../core/services/ws/wsClientManager';
|
||||
import tools from '../../core/utils/system/tool';
|
||||
|
||||
class BotService {
|
||||
/**
|
||||
|
@ -1,10 +1,10 @@
|
||||
import express from 'express';
|
||||
import FileService from './file.service';
|
||||
import logger from '../../utils/core/logger';
|
||||
import response from '../../utils/core/response';
|
||||
import paths from '../../utils/core/path';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
import response from '../../core/utils/system/response';
|
||||
import paths from '../../core/utils/system/path';
|
||||
import multer from 'multer';
|
||||
import tools from '../../utils/modules/tools';
|
||||
import tools from '../../core/utils/modules/tools';
|
||||
|
||||
const uploadDir = paths.get('uploads');
|
||||
const upload = multer({
|
||||
|
@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs/promises';
|
||||
import paths from '../../utils/core/path';
|
||||
import logger from '../../utils/core/logger';
|
||||
import paths from '../../core/utils/system/path';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
import { existsSync } from 'fs';
|
||||
|
||||
class FileService {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import sampleService from './sample.service';
|
||||
import response from '../../utils/core/response';
|
||||
import response from '../../core/utils/system/response';
|
||||
|
||||
class SampleController {
|
||||
private readonly router: express.Router;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import logger from '../../utils/core/logger';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
|
||||
class SampleService {
|
||||
public async getHello() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import tools from '../../utils/modules/tools';
|
||||
import response from '../../utils/core/response';
|
||||
import tools from '../../core/utils/modules/tools';
|
||||
import response from '../../core/utils/system/response';
|
||||
import SystemService from './system.service';
|
||||
|
||||
class SystemController {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import System from '../../utils/core/system';
|
||||
import System from '../../core/utils/system/system';
|
||||
import fs from 'fs/promises';
|
||||
import logger from '../../utils/core/logger';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
import path from 'path';
|
||||
import paths from '../../utils/core/path';
|
||||
import paths from '../../core/utils/system/path';
|
||||
|
||||
class SystemService {
|
||||
public async systemRestart() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import express from 'express';
|
||||
import TestService from './test.service';
|
||||
import response from '../../utils/core/response';
|
||||
import logger from '../../utils/core/logger';
|
||||
import response from '../../core/utils/system/response';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
|
||||
class TestController {
|
||||
private readonly router: express.Router;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import wsClientManager from '../../services/ws/wsClientManager';
|
||||
import logger from '../../utils/core/logger';
|
||||
import wsClientManager from '../../core/services/ws/wsClientManager';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
|
||||
class TestService {
|
||||
public async test() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import express from 'express';
|
||||
import WordsService from './words.service';
|
||||
import response from '../../utils/core/response';
|
||||
import tools from '../../utils/modules/tools';
|
||||
import response from '../../core/utils/system/response';
|
||||
import tools from '../../core/utils/modules/tools';
|
||||
|
||||
class WordsController {
|
||||
private readonly router: express.Router;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import paths from '../../utils/core/path';
|
||||
import paths from '../../core/utils/system/path';
|
||||
import fs from 'fs/promises';
|
||||
import logger from '../../utils/core/logger';
|
||||
import logger from '../../core/utils/system/logger';
|
||||
|
||||
class WordsService {
|
||||
private wordCache: Record<string, string[]> = {}; //缓存
|
||||
|
@ -1,6 +1,6 @@
|
||||
import WebSocket from 'ws';
|
||||
import axios from 'axios';
|
||||
import logger from '../utils/core/logger';
|
||||
import logger from '../core/utils/system/logger';
|
||||
|
||||
const WS_URL = 'ws://127.0.0.1:4001';
|
||||
const WS_SECRET = '114514';
|
||||
|
Loading…
x
Reference in New Issue
Block a user