File size: 121,424 Bytes
813eca2
1
{"version":3,"sources":["../src/lib/environment.ts","../src/lib/configs/service-config.ts","../src/lib/util.ts","../src/lib/http-status-codes.ts","../src/lib/configs/system-config.ts","../src/lib/config.ts","../src/lib/logger.ts","../src/lib/initialize.ts","../src/lib/server.ts","../src/lib/request/Request.ts","../src/lib/exceptions/Exception.ts","../src/lib/exceptions/APIException.ts","../src/api/consts/exceptions.ts","../src/lib/response/Response.ts","../src/lib/response/Body.ts","../src/lib/response/FailureBody.ts","../src/lib/consts/exceptions.ts","../src/api/routes/index.ts","../src/api/routes/chat.ts","../src/api/controllers/chat.ts","../src/api/routes/ping.ts","../src/api/routes/token.ts","../src/api/routes/models.ts","../src/index.ts"],"sourcesContent":["import path from 'path';\r\n\r\nimport fs from 'fs-extra';\r\nimport minimist from 'minimist';\r\nimport _ from 'lodash';\r\n\r\nconst cmdArgs = minimist(process.argv.slice(2));  //获取命令行参数\r\nconst envVars = process.env;  //获取环境变量\r\n\r\nclass Environment {\r\n\r\n    /** 命令行参数 */\r\n    cmdArgs: any;\r\n    /** 环境变量 */\r\n    envVars: any;\r\n    /** 环境名称 */\r\n    env?: string;\r\n    /** 服务名称 */\r\n    name?: string;\r\n    /** 服务地址 */\r\n    host?: string;\r\n    /** 服务端口 */\r\n    port?: number;\r\n    /** 包参数 */\r\n    package: any;\r\n\r\n    constructor(options: any = {}) {\r\n        const { cmdArgs, envVars, package: _package } = options;\r\n        this.cmdArgs = cmdArgs;\r\n        this.envVars = envVars;\r\n        this.env = _.defaultTo(cmdArgs.env || envVars.SERVER_ENV, 'dev');\r\n        this.name = cmdArgs.name || envVars.SERVER_NAME || undefined;\r\n        this.host = cmdArgs.host || envVars.SERVER_HOST || undefined;\r\n        this.port = Number(cmdArgs.port || envVars.SERVER_PORT) ? Number(cmdArgs.port || envVars.SERVER_PORT) : undefined;\r\n        this.package = _package;\r\n    }\r\n\r\n}\r\n\r\nexport default new Environment({\r\n    cmdArgs,\r\n    envVars,\r\n    package: JSON.parse(fs.readFileSync(path.join(path.resolve(), \"package.json\")).toString())\r\n});","import path from 'path';\r\n\r\nimport fs from 'fs-extra';\r\nimport yaml from 'yaml';\r\nimport _ from 'lodash';\r\n\r\nimport environment from '../environment.ts';\r\nimport util from '../util.ts';\r\n\r\nconst CONFIG_PATH = path.join(path.resolve(), 'configs/', environment.env, \"/service.yml\");\r\n\r\n/**\r\n * 服务配置\r\n */\r\nexport class ServiceConfig {\r\n\r\n    /** 服务名称 */\r\n    name: string;\r\n    /** @type {string} 服务绑定主机地址 */\r\n    host;\r\n    /** @type {number} 服务绑定端口 */\r\n    port;\r\n    /** @type {string} 服务路由前缀 */\r\n    urlPrefix;\r\n    /** @type {string} 服务绑定地址(外部访问地址) */\r\n    bindAddress;\r\n\r\n    constructor(options?: any) {\r\n        const { name, host, port, urlPrefix, bindAddress } = options || {};\r\n        this.name = _.defaultTo(name, 'deepseek-free-api');\r\n        this.host = _.defaultTo(host, '0.0.0.0');\r\n        this.port = _.defaultTo(port, 5566);\r\n        this.urlPrefix = _.defaultTo(urlPrefix, '');\r\n        this.bindAddress = bindAddress;\r\n    }\r\n\r\n    get addressHost() {\r\n        if(this.bindAddress) return this.bindAddress;\r\n        const ipAddresses = util.getIPAddressesByIPv4();\r\n        for(let ipAddress of ipAddresses) {\r\n            if(ipAddress === this.host)\r\n                return ipAddress;\r\n        }\r\n        return ipAddresses[0] || \"127.0.0.1\";\r\n    }\r\n\r\n    get address() {\r\n        return `${this.addressHost}:${this.port}`;\r\n    }\r\n\r\n    get pageDirUrl() {\r\n        return `http://127.0.0.1:${this.port}/page`;\r\n    }\r\n\r\n    get publicDirUrl() {\r\n        return `http://127.0.0.1:${this.port}/public`;\r\n    }\r\n\r\n    static load() {\r\n        const external = _.pickBy(environment, (v, k) => [\"name\", \"host\", \"port\"].includes(k) && !_.isUndefined(v));\r\n        if(!fs.pathExistsSync(CONFIG_PATH)) return new ServiceConfig(external);\r\n        const data = yaml.parse(fs.readFileSync(CONFIG_PATH).toString());\r\n        return new ServiceConfig({ ...data, ...external });\r\n    }\r\n\r\n}\r\n\r\nexport default ServiceConfig.load();","import os from \"os\";\r\nimport path from \"path\";\r\nimport crypto from \"crypto\";\r\nimport { Readable, Writable } from \"stream\";\r\n\r\nimport \"colors\";\r\nimport mime from \"mime\";\r\nimport axios from \"axios\";\r\nimport fs from \"fs-extra\";\r\nimport { v1 as uuid } from \"uuid\";\r\nimport { format as dateFormat } from \"date-fns\";\r\nimport CRC32 from \"crc-32\";\r\nimport randomstring from \"randomstring\";\r\nimport _ from \"lodash\";\r\nimport { CronJob } from \"cron\";\r\n\r\nimport HTTP_STATUS_CODE from \"./http-status-codes.ts\";\r\n\r\nconst autoIdMap = new Map();\r\n\r\nconst util = {\r\n  is2DArrays(value: any) {\r\n    return (\r\n      _.isArray(value) &&\r\n      (!value[0] || (_.isArray(value[0]) && _.isArray(value[value.length - 1])))\r\n    );\r\n  },\r\n\r\n  uuid: (separator = true) => (separator ? uuid() : uuid().replace(/\\-/g, \"\")),\r\n\r\n  autoId: (prefix = \"\") => {\r\n    let index = autoIdMap.get(prefix);\r\n    if (index > 999999) index = 0; //超过最大数字则重置为0\r\n    autoIdMap.set(prefix, (index || 0) + 1);\r\n    return `${prefix}${index || 1}`;\r\n  },\r\n\r\n  ignoreJSONParse(value: string) {\r\n    const result = _.attempt(() => JSON.parse(value));\r\n    if (_.isError(result)) return null;\r\n    return result;\r\n  },\r\n\r\n  generateRandomString(options: any): string {\r\n    return randomstring.generate(options);\r\n  },\r\n\r\n  getResponseContentType(value: any): string | null {\r\n    return value.headers\r\n      ? value.headers[\"content-type\"] || value.headers[\"Content-Type\"]\r\n      : null;\r\n  },\r\n\r\n  mimeToExtension(value: string) {\r\n    let extension = mime.getExtension(value);\r\n    if (extension == \"mpga\") return \"mp3\";\r\n    return extension;\r\n  },\r\n\r\n  extractURLExtension(value: string) {\r\n    const extname = path.extname(new URL(value).pathname);\r\n    return extname.substring(1).toLowerCase();\r\n  },\r\n\r\n  createCronJob(cronPatterns: any, callback?: Function) {\r\n    if (!_.isFunction(callback))\r\n      throw new Error(\"callback must be an Function\");\r\n    return new CronJob(\r\n      cronPatterns,\r\n      () => callback(),\r\n      null,\r\n      false,\r\n      \"Asia/Shanghai\"\r\n    );\r\n  },\r\n\r\n  getDateString(format = \"yyyy-MM-dd\", date = new Date()) {\r\n    return dateFormat(date, format);\r\n  },\r\n\r\n  getIPAddressesByIPv4(): string[] {\r\n    const interfaces = os.networkInterfaces();\r\n    const addresses = [];\r\n    for (let name in interfaces) {\r\n      const networks = interfaces[name];\r\n      const results = networks.filter(\r\n        (network) =>\r\n          network.family === \"IPv4\" &&\r\n          network.address !== \"127.0.0.1\" &&\r\n          !network.internal\r\n      );\r\n      if (results[0] && results[0].address) addresses.push(results[0].address);\r\n    }\r\n    return addresses;\r\n  },\r\n\r\n  getMACAddressesByIPv4(): string[] {\r\n    const interfaces = os.networkInterfaces();\r\n    const addresses = [];\r\n    for (let name in interfaces) {\r\n      const networks = interfaces[name];\r\n      const results = networks.filter(\r\n        (network) =>\r\n          network.family === \"IPv4\" &&\r\n          network.address !== \"127.0.0.1\" &&\r\n          !network.internal\r\n      );\r\n      if (results[0] && results[0].mac) addresses.push(results[0].mac);\r\n    }\r\n    return addresses;\r\n  },\r\n\r\n  generateSSEData(event?: string, data?: string, retry?: number) {\r\n    return `event: ${event || \"message\"}\\ndata: ${(data || \"\")\r\n      .replace(/\\n/g, \"\\\\n\")\r\n      .replace(/\\s/g, \"\\\\s\")}\\nretry: ${retry || 3000}\\n\\n`;\r\n  },\r\n\r\n  buildDataBASE64(type, ext, buffer) {\r\n    return `data:${type}/${ext.replace(\"jpg\", \"jpeg\")};base64,${buffer.toString(\r\n      \"base64\"\r\n    )}`;\r\n  },\r\n\r\n  isLinux() {\r\n    return os.platform() !== \"win32\";\r\n  },\r\n\r\n  isIPAddress(value) {\r\n    return (\r\n      _.isString(value) &&\r\n      (/^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\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-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*/.test(\r\n          value\r\n        ))\r\n    );\r\n  },\r\n\r\n  isPort(value) {\r\n    return _.isNumber(value) && value > 0 && value < 65536;\r\n  },\r\n\r\n  isReadStream(value): boolean {\r\n    return (\r\n      value &&\r\n      (value instanceof Readable || \"readable\" in value || value.readable)\r\n    );\r\n  },\r\n\r\n  isWriteStream(value): boolean {\r\n    return (\r\n      value &&\r\n      (value instanceof Writable || \"writable\" in value || value.writable)\r\n    );\r\n  },\r\n\r\n  isHttpStatusCode(value) {\r\n    return _.isNumber(value) && Object.values(HTTP_STATUS_CODE).includes(value);\r\n  },\r\n\r\n  isURL(value) {\r\n    return !_.isUndefined(value) && /^(http|https)/.test(value);\r\n  },\r\n\r\n  isSrc(value) {\r\n    return !_.isUndefined(value) && /^\\/.+\\.[0-9a-zA-Z]+(\\?.+)?$/.test(value);\r\n  },\r\n\r\n  isBASE64(value) {\r\n    return !_.isUndefined(value) && /^[a-zA-Z0-9\\/\\+]+(=?)+$/.test(value);\r\n  },\r\n\r\n  isBASE64Data(value) {\r\n    return /^data:/.test(value);\r\n  },\r\n\r\n  extractBASE64DataFormat(value): string | null {\r\n    const match = value.trim().match(/^data:(.+);base64,/);\r\n    if (!match) return null;\r\n    return match[1];\r\n  },\r\n\r\n  removeBASE64DataHeader(value): string {\r\n    return value.replace(/^data:(.+);base64,/, \"\");\r\n  },\r\n\r\n  isDataString(value): boolean {\r\n    return /^(base64|json):/.test(value);\r\n  },\r\n\r\n  isStringNumber(value) {\r\n    return _.isFinite(Number(value));\r\n  },\r\n\r\n  isUnixTimestamp(value) {\r\n    return /^[0-9]{10}$/.test(`${value}`);\r\n  },\r\n\r\n  isTimestamp(value) {\r\n    return /^[0-9]{13}$/.test(`${value}`);\r\n  },\r\n\r\n  isEmail(value) {\r\n    return /^([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+\\.[a-zA-Z]{2,3}$/.test(\r\n      value\r\n    );\r\n  },\r\n\r\n  isAsyncFunction(value) {\r\n    return Object.prototype.toString.call(value) === \"[object AsyncFunction]\";\r\n  },\r\n\r\n  async isAPNG(filePath) {\r\n    let head;\r\n    const readStream = fs.createReadStream(filePath, { start: 37, end: 40 });\r\n    const readPromise = new Promise((resolve, reject) => {\r\n      readStream.once(\"end\", resolve);\r\n      readStream.once(\"error\", reject);\r\n    });\r\n    readStream.once(\"data\", (data) => (head = data));\r\n    await readPromise;\r\n    return head.compare(Buffer.from([0x61, 0x63, 0x54, 0x4c])) === 0;\r\n  },\r\n\r\n  unixTimestamp() {\r\n    return parseInt(`${Date.now() / 1000}`);\r\n  },\r\n\r\n  timestamp() {\r\n    return Date.now();\r\n  },\r\n\r\n  urlJoin(...values) {\r\n    let url = \"\";\r\n    for (let i = 0; i < values.length; i++)\r\n      url += `${i > 0 ? \"/\" : \"\"}${values[i]\r\n        .replace(/^\\/*/, \"\")\r\n        .replace(/\\/*$/, \"\")}`;\r\n    return url;\r\n  },\r\n\r\n  millisecondsToHmss(milliseconds) {\r\n    if (_.isString(milliseconds)) return milliseconds;\r\n    milliseconds = parseInt(milliseconds);\r\n    const sec = Math.floor(milliseconds / 1000);\r\n    const hours = Math.floor(sec / 3600);\r\n    const minutes = Math.floor((sec - hours * 3600) / 60);\r\n    const seconds = sec - hours * 3600 - minutes * 60;\r\n    const ms = (milliseconds % 60000) - seconds * 1000;\r\n    return `${hours > 9 ? hours : \"0\" + hours}:${\r\n      minutes > 9 ? minutes : \"0\" + minutes\r\n    }:${seconds > 9 ? seconds : \"0\" + seconds}.${ms}`;\r\n  },\r\n\r\n  millisecondsToTimeString(milliseconds) {\r\n    if (milliseconds < 1000) return `${milliseconds}ms`;\r\n    if (milliseconds < 60000)\r\n      return `${parseFloat((milliseconds / 1000).toFixed(2))}s`;\r\n    return `${Math.floor(milliseconds / 1000 / 60)}m${Math.floor(\r\n      (milliseconds / 1000) % 60\r\n    )}s`;\r\n  },\r\n\r\n  rgbToHex(r, g, b): string {\r\n    return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\r\n  },\r\n\r\n  hexToRgb(hex) {\r\n    const value = parseInt(hex.replace(/^#/, \"\"), 16);\r\n    return [(value >> 16) & 255, (value >> 8) & 255, value & 255];\r\n  },\r\n\r\n  md5(value) {\r\n    return crypto.createHash(\"md5\").update(value).digest(\"hex\");\r\n  },\r\n\r\n  crc32(value) {\r\n    return _.isBuffer(value) ? CRC32.buf(value) : CRC32.str(value);\r\n  },\r\n\r\n  arrayParse(value): any[] {\r\n    return _.isArray(value) ? value : [value];\r\n  },\r\n\r\n  booleanParse(value) {\r\n    return value === \"true\" || value === true ? true : false;\r\n  },\r\n\r\n  encodeBASE64(value) {\r\n    return Buffer.from(value).toString(\"base64\");\r\n  },\r\n\r\n  decodeBASE64(value) {\r\n    return Buffer.from(value, \"base64\").toString();\r\n  },\r\n\r\n  async fetchFileBASE64(url: string) {\r\n    const result = await axios.get(url, {\r\n      responseType: \"arraybuffer\",\r\n    });\r\n    return result.data.toString(\"base64\");\r\n  },\r\n};\r\n\r\nexport default util;\r\n","export default {\r\n\r\n    CONTINUE: 100,  //客户端应当继续发送请求。这个临时响应是用来通知客户端它的部分请求已经被服务器接收,且仍未被拒绝。客户端应当继续发送请求的剩余部分,或者如果请求已经完成,忽略这个响应。服务器必须在请求完成后向客户端发送一个最终响应\r\n    SWITCHING_PROTOCOLS: 101,  //服务器已经理解了客户端的请求,并将通过Upgrade 消息头通知客户端采用不同的协议来完成这个请求。在发送完这个响应最后的空行后,服务器将会切换到在Upgrade 消息头中定义的那些协议。只有在切换新的协议更有好处的时候才应该采取类似措施。例如,切换到新的HTTP 版本比旧版本更有优势,或者切换到一个实时且同步的协议以传送利用此类特性的资源\r\n    PROCESSING: 102,  //处理将被继续执行\r\n\r\n    OK: 200,  //请求已成功,请求所希望的响应头或数据体将随此响应返回\r\n    CREATED: 201,  //请求已经被实现,而且有一个新的资源已经依据请求的需要而建立,且其 URI 已经随Location 头信息返回。假如需要的资源无法及时建立的话,应当返回 '202 Accepted'\r\n    ACCEPTED: 202,  //服务器已接受请求,但尚未处理。正如它可能被拒绝一样,最终该请求可能会也可能不会被执行。在异步操作的场合下,没有比发送这个状态码更方便的做法了。返回202状态码的响应的目的是允许服务器接受其他过程的请求(例如某个每天只执行一次的基于批处理的操作),而不必让客户端一直保持与服务器的连接直到批处理操作全部完成。在接受请求处理并返回202状态码的响应应当在返回的实体中包含一些指示处理当前状态的信息,以及指向处理状态监视器或状态预测的指针,以便用户能够估计操作是否已经完成\r\n    NON_AUTHORITATIVE_INFO: 203,  //服务器已成功处理了请求,但返回的实体头部元信息不是在原始服务器上有效的确定集合,而是来自本地或者第三方的拷贝。当前的信息可能是原始版本的子集或者超集。例如,包含资源的元数据可能导致原始服务器知道元信息的超级。使用此状态码不是必须的,而且只有在响应不使用此状态码便会返回200 OK的情况下才是合适的\r\n    NO_CONTENT: 204,  //服务器成功处理了请求,但不需要返回任何实体内容,并且希望返回更新了的元信息。响应可能通过实体头部的形式,返回新的或更新后的元信息。如果存在这些头部信息,则应当与所请求的变量相呼应。如果客户端是浏览器的话,那么用户浏览器应保留发送了该请求的页面,而不产生任何文档视图上的变化,即使按照规范新的或更新后的元信息应当被应用到用户浏览器活动视图中的文档。由于204响应被禁止包含任何消息体,因此它始终以消息头后的第一个空行结尾\r\n    RESET_CONTENT: 205,  //服务器成功处理了请求,且没有返回任何内容。但是与204响应不同,返回此状态码的响应要求请求者重置文档视图。该响应主要是被用于接受用户输入后,立即重置表单,以便用户能够轻松地开始另一次输入。与204响应一样,该响应也被禁止包含任何消息体,且以消息头后的第一个空行结束\r\n    PARTIAL_CONTENT: 206,  //服务器已经成功处理了部分 GET 请求。类似于FlashGet或者迅雷这类的HTTP下载工具都是使用此类响应实现断点续传或者将一个大文档分解为多个下载段同时下载。该请求必须包含 Range 头信息来指示客户端希望得到的内容范围,并且可能包含 If-Range 来作为请求条件。响应必须包含如下的头部域:Content-Range 用以指示本次响应中返回的内容的范围;如果是Content-Type为multipart/byteranges的多段下载,则每一段multipart中都应包含Content-Range域用以指示本段的内容范围。假如响应中包含Content-Length,那么它的数值必须匹配它返回的内容范围的真实字节数。Date和ETag或Content-Location,假如同样的请求本应该返回200响应。Expires, Cache-Control,和/或 Vary,假如其值可能与之前相同变量的其他响应对应的值不同的话。假如本响应请求使用了 If-Range 强缓存验证,那么本次响应不应该包含其他实体头;假如本响应的请求使用了 If-Range 弱缓存验证,那么本次响应禁止包含其他实体头;这避免了缓存的实体内容和更新了的实体头信息之间的不一致。否则,本响应就应当包含所有本应该返回200响应中应当返回的所有实体头部域。假如 ETag 或 Latest-Modified 头部不能精确匹配的话,则客户端缓存应禁止将206响应返回的内容与之前任何缓存过的内容组合在一起。任何不支持 Range 以及 Content-Range 头的缓存都禁止缓存206响应返回的内容\r\n    MULTIPLE_STATUS: 207,  //代表之后的消息体将是一个XML消息,并且可能依照之前子请求数量的不同,包含一系列独立的响应代码\r\n\r\n    MULTIPLE_CHOICES: 300,  //被请求的资源有一系列可供选择的回馈信息,每个都有自己特定的地址和浏览器驱动的商议信息。用户或浏览器能够自行选择一个首选的地址进行重定向。除非这是一个HEAD请求,否则该响应应当包括一个资源特性及地址的列表的实体,以便用户或浏览器从中选择最合适的重定向地址。这个实体的格式由Content-Type定义的格式所决定。浏览器可能根据响应的格式以及浏览器自身能力,自动作出最合适的选择。当然,RFC 2616规范并没有规定这样的自动选择该如何进行。如果服务器本身已经有了首选的回馈选择,那么在Location中应当指明这个回馈的 URI;浏览器可能会将这个 Location 值作为自动重定向的地址。此外,除非额外指定,否则这个响应也是可缓存的\r\n    MOVED_PERMANENTLY: 301,  //被请求的资源已永久移动到新位置,并且将来任何对此资源的引用都应该使用本响应返回的若干个URI之一。如果可能,拥有链接编辑功能的客户端应当自动把请求的地址修改为从服务器反馈回来的地址。除非额外指定,否则这个响应也是可缓存的。新的永久性的URI应当在响应的Location域中返回。除非这是一个HEAD请求,否则响应的实体中应当包含指向新的URI的超链接及简短说明。如果这不是一个GET或者HEAD请求,因此浏览器禁止自动进行重定向,除非得到用户的确认,因为请求的条件可能因此发生变化。注意:对于某些使用 HTTP/1.0 协议的浏览器,当它们发送的POST请求得到了一个301响应的话,接下来的重定向请求将会变成GET方式\r\n    FOUND: 302,  //请求的资源现在临时从不同的URI响应请求。由于这样的重定向是临时的,客户端应当继续向原有地址发送以后的请求。只有在Cache-Control或Expires中进行了指定的情况下,这个响应才是可缓存的。新的临时性的URI应当在响应的 Location 域中返回。除非这是一个HEAD请求,否则响应的实体中应当包含指向新的URI的超链接及简短说明。如果这不是一个GET或者HEAD请求,那么浏览器禁止自动进行重定向,除非得到用户的确认,因为请求的条件可能因此发生变化。注意:虽然RFC 1945和RFC 2068规范不允许客户端在重定向时改变请求的方法,但是很多现存的浏览器将302响应视作为303响应,并且使用GET方式访问在Location中规定的URI,而无视原先请求的方法。状态码303和307被添加了进来,用以明确服务器期待客户端进行何种反应\r\n    SEE_OTHER: 303,  //对应当前请求的响应可以在另一个URI上被找到,而且客户端应当采用 GET 的方式访问那个资源。这个方法的存在主要是为了允许由脚本激活的POST请求输出重定向到一个新的资源。这个新的 URI 不是原始资源的替代引用。同时,303响应禁止被缓存。当然,第二个请求(重定向)可能被缓存。新的 URI 应当在响应的Location域中返回。除非这是一个HEAD请求,否则响应的实体中应当包含指向新的URI的超链接及简短说明。注意:许多 HTTP/1.1 版以前的浏览器不能正确理解303状态。如果需要考虑与这些浏览器之间的互动,302状态码应该可以胜任,因为大多数的浏览器处理302响应时的方式恰恰就是上述规范要求客户端处理303响应时应当做的\r\n    NOT_MODIFIED: 304,  //如果客户端发送了一个带条件的GET请求且该请求已被允许,而文档的内容(自上次访问以来或者根据请求的条件)并没有改变,则服务器应当返回这个状态码。304响应禁止包含消息体,因此始终以消息头后的第一个空行结尾。该响应必须包含以下的头信息:Date,除非这个服务器没有时钟。假如没有时钟的服务器也遵守这些规则,那么代理服务器以及客户端可以自行将Date字段添加到接收到的响应头中去(正如RFC 2068中规定的一样),缓存机制将会正常工作。ETag或 Content-Location,假如同样的请求本应返回200响应。Expires, Cache-Control,和/或Vary,假如其值可能与之前相同变量的其他响应对应的值不同的话。假如本响应请求使用了强缓存验证,那么本次响应不应该包含其他实体头;否则(例如,某个带条件的 GET 请求使用了弱缓存验证),本次响应禁止包含其他实体头;这避免了缓存了的实体内容和更新了的实体头信息之间的不一致。假如某个304响应指明了当前某个实体没有缓存,那么缓存系统必须忽视这个响应,并且重复发送不包含限制条件的请求。假如接收到一个要求更新某个缓存条目的304响应,那么缓存系统必须更新整个条目以反映所有在响应中被更新的字段的值\r\n    USE_PROXY: 305,  //被请求的资源必须通过指定的代理才能被访问。Location域中将给出指定的代理所在的URI信息,接收者需要重复发送一个单独的请求,通过这个代理才能访问相应资源。只有原始服务器才能建立305响应。注意:RFC 2068中没有明确305响应是为了重定向一个单独的请求,而且只能被原始服务器建立。忽视这些限制可能导致严重的安全后果\r\n    UNUSED: 306,  //在最新版的规范中,306状态码已经不再被使用\r\n    TEMPORARY_REDIRECT: 307,  //请求的资源现在临时从不同的URI 响应请求。由于这样的重定向是临时的,客户端应当继续向原有地址发送以后的请求。只有在Cache-Control或Expires中进行了指定的情况下,这个响应才是可缓存的。新的临时性的URI 应当在响应的Location域中返回。除非这是一个HEAD请求,否则响应的实体中应当包含指向新的URI 的超链接及简短说明。因为部分浏览器不能识别307响应,因此需要添加上述必要信息以便用户能够理解并向新的 URI 发出访问请求。如果这不是一个GET或者HEAD请求,那么浏览器禁止自动进行重定向,除非得到用户的确认,因为请求的条件可能因此发生变化\r\n\r\n    BAD_REQUEST: 400,  //1.语义有误,当前请求无法被服务器理解。除非进行修改,否则客户端不应该重复提交这个请求 2.请求参数有误\r\n    UNAUTHORIZED: 401,  //当前请求需要用户验证。该响应必须包含一个适用于被请求资源的 WWW-Authenticate 信息头用以询问用户信息。客户端可以重复提交一个包含恰当的 Authorization 头信息的请求。如果当前请求已经包含了 Authorization 证书,那么401响应代表着服务器验证已经拒绝了那些证书。如果401响应包含了与前一个响应相同的身份验证询问,且浏览器已经至少尝试了一次验证,那么浏览器应当向用户展示响应中包含的实体信息,因为这个实体信息中可能包含了相关诊断信息。参见RFC 2617\r\n    PAYMENT_REQUIRED: 402,  //该状态码是为了将来可能的需求而预留的\r\n    FORBIDDEN: 403,  //服务器已经理解请求,但是拒绝执行它。与401响应不同的是,身份验证并不能提供任何帮助,而且这个请求也不应该被重复提交。如果这不是一个HEAD请求,而且服务器希望能够讲清楚为何请求不能被执行,那么就应该在实体内描述拒绝的原因。当然服务器也可以返回一个404响应,假如它不希望让客户端获得任何信息\r\n    NOT_FOUND: 404,  //请求失败,请求所希望得到的资源未被在服务器上发现。没有信息能够告诉用户这个状况到底是暂时的还是永久的。假如服务器知道情况的话,应当使用410状态码来告知旧资源因为某些内部的配置机制问题,已经永久的不可用,而且没有任何可以跳转的地址。404这个状态码被广泛应用于当服务器不想揭示到底为何请求被拒绝或者没有其他适合的响应可用的情况下\r\n    METHOD_NOT_ALLOWED: 405,  //请求行中指定的请求方法不能被用于请求相应的资源。该响应必须返回一个Allow 头信息用以表示出当前资源能够接受的请求方法的列表。鉴于PUT,DELETE方法会对服务器上的资源进行写操作,因而绝大部分的网页服务器都不支持或者在默认配置下不允许上述请求方法,对于此类请求均会返回405错误\r\n    NO_ACCEPTABLE: 406,  //请求的资源的内容特性无法满足请求头中的条件,因而无法生成响应实体。除非这是一个 HEAD 请求,否则该响应就应当返回一个包含可以让用户或者浏览器从中选择最合适的实体特性以及地址列表的实体。实体的格式由Content-Type头中定义的媒体类型决定。浏览器可以根据格式及自身能力自行作出最佳选择。但是,规范中并没有定义任何作出此类自动选择的标准\r\n    PROXY_AUTHENTICATION_REQUIRED: 407,  //与401响应类似,只不过客户端必须在代理服务器上进行身份验证。代理服务器必须返回一个Proxy-Authenticate用以进行身份询问。客户端可以返回一个Proxy-Authorization信息头用以验证。参见RFC 2617\r\n    REQUEST_TIMEOUT: 408,  //请求超时。客户端没有在服务器预备等待的时间内完成一个请求的发送。客户端可以随时再次提交这一请求而无需进行任何更改\r\n    CONFLICT: 409,  //由于和被请求的资源的当前状态之间存在冲突,请求无法完成。这个代码只允许用在这样的情况下才能被使用:用户被认为能够解决冲突,并且会重新提交新的请求。该响应应当包含足够的信息以便用户发现冲突的源头。冲突通常发生于对PUT请求的处理中。例如,在采用版本检查的环境下,某次PUT提交的对特定资源的修改请求所附带的版本信息与之前的某个(第三方)请求向冲突,那么此时服务器就应该返回一个409错误,告知用户请求无法完成。此时,响应实体中很可能会包含两个冲突版本之间的差异比较,以便用户重新提交归并以后的新版本\r\n    GONE: 410,  //被请求的资源在服务器上已经不再可用,而且没有任何已知的转发地址。这样的状况应当被认为是永久性的。如果可能,拥有链接编辑功能的客户端应当在获得用户许可后删除所有指向这个地址的引用。如果服务器不知道或者无法确定这个状况是否是永久的,那么就应该使用404状态码。除非额外说明,否则这个响应是可缓存的。410响应的目的主要是帮助网站管理员维护网站,通知用户该资源已经不再可用,并且服务器拥有者希望所有指向这个资源的远端连接也被删除。这类事件在限时、增值服务中很普遍。同样,410响应也被用于通知客户端在当前服务器站点上,原本属于某个个人的资源已经不再可用。当然,是否需要把所有永久不可用的资源标记为'410 Gone',以及是否需要保持此标记多长时间,完全取决于服务器拥有者\r\n    LENGTH_REQUIRED: 411,  //服务器拒绝在没有定义Content-Length头的情况下接受请求。在添加了表明请求消息体长度的有效Content-Length头之后,客户端可以再次提交该请求 \r\n    PRECONDITION_FAILED: 412,  //服务器在验证在请求的头字段中给出先决条件时,没能满足其中的一个或多个。这个状态码允许客户端在获取资源时在请求的元信息(请求头字段数据)中设置先决条件,以此避免该请求方法被应用到其希望的内容以外的资源上\r\n    REQUEST_ENTITY_TOO_LARGE: 413,  //服务器拒绝处理当前请求,因为该请求提交的实体数据大小超过了服务器愿意或者能够处理的范围。此种情况下,服务器可以关闭连接以免客户端继续发送此请求。如果这个状况是临时的,服务器应当返回一个 Retry-After 的响应头,以告知客户端可以在多少时间以后重新尝试\r\n    REQUEST_URI_TOO_LONG: 414,  //请求的URI长度超过了服务器能够解释的长度,因此服务器拒绝对该请求提供服务。这比较少见,通常的情况包括:本应使用POST方法的表单提交变成了GET方法,导致查询字符串(Query String)过长。重定向URI “黑洞”,例如每次重定向把旧的URI作为新的URI的一部分,导致在若干次重定向后URI超长。客户端正在尝试利用某些服务器中存在的安全漏洞攻击服务器。这类服务器使用固定长度的缓冲读取或操作请求的URI,当GET后的参数超过某个数值后,可能会产生缓冲区溢出,导致任意代码被执行[1]。没有此类漏洞的服务器,应当返回414状态码\r\n    UNSUPPORTED_MEDIA_TYPE: 415,  //对于当前请求的方法和所请求的资源,请求中提交的实体并不是服务器中所支持的格式,因此请求被拒绝\r\n    REQUESTED_RANGE_NOT_SATISFIABLE: 416,  //如果请求中包含了Range请求头,并且Range中指定的任何数据范围都与当前资源的可用范围不重合,同时请求中又没有定义If-Range请求头,那么服务器就应当返回416状态码。假如Range使用的是字节范围,那么这种情况就是指请求指定的所有数据范围的首字节位置都超过了当前资源的长度。服务器也应当在返回416状态码的同时,包含一个Content-Range实体头,用以指明当前资源的长度。这个响应也被禁止使用multipart/byteranges作为其 Content-Type\r\n    EXPECTION_FAILED: 417,  //在请求头Expect中指定的预期内容无法被服务器满足,或者这个服务器是一个代理服务器,它有明显的证据证明在当前路由的下一个节点上,Expect的内容无法被满足\r\n    TOO_MANY_CONNECTIONS: 421,  //从当前客户端所在的IP地址到服务器的连接数超过了服务器许可的最大范围。通常,这里的IP地址指的是从服务器上看到的客户端地址(比如用户的网关或者代理服务器地址)。在这种情况下,连接数的计算可能涉及到不止一个终端用户\r\n    UNPROCESSABLE_ENTITY: 422,  //请求格式正确,但是由于含有语义错误,无法响应\r\n    FAILED_DEPENDENCY: 424,  //由于之前的某个请求发生的错误,导致当前请求失败,例如PROPPATCH\r\n    UNORDERED_COLLECTION: 425,  //在WebDav Advanced Collections 草案中定义,但是未出现在《WebDAV 顺序集协议》(RFC 3658)中\r\n    UPGRADE_REQUIRED: 426,  //客户端应当切换到TLS/1.0\r\n    RETRY_WITH: 449,  //由微软扩展,代表请求应当在执行完适当的操作后进行重试\r\n\r\n    INTERNAL_SERVER_ERROR: 500,  //服务器遇到了一个未曾预料的状况,导致了它无法完成对请求的处理。一般来说,这个问题都会在服务器的程序码出错时出现\r\n    NOT_IMPLEMENTED: 501, //服务器不支持当前请求所需要的某个功能。当服务器无法识别请求的方法,并且无法支持其对任何资源的请求\r\n    BAD_GATEWAY: 502, //作为网关或者代理工作的服务器尝试执行请求时,从上游服务器接收到无效的响应\r\n    SERVICE_UNAVAILABLE: 503,  //由于临时的服务器维护或者过载,服务器当前无法处理请求。这个状况是临时的,并且将在一段时间以后恢复。如果能够预计延迟时间,那么响应中可以包含一个 Retry-After 头用以标明这个延迟时间。如果没有给出这个 Retry-After 信息,那么客户端应当以处理500响应的方式处理它。注意:503状态码的存在并不意味着服务器在过载的时候必须使用它。某些服务器只不过是希望拒绝客户端的连接\r\n    GATEWAY_TIMEOUT: 504,  //作为网关或者代理工作的服务器尝试执行请求时,未能及时从上游服务器(URI标识出的服务器,例如HTTP、FTP、LDAP)或者辅助服务器(例如DNS)收到响应。注意:某些代理服务器在DNS查询超时时会返回400或者500错误\r\n    HTTP_VERSION_NOT_SUPPORTED: 505,  //服务器不支持,或者拒绝支持在请求中使用的HTTP版本。这暗示着服务器不能或不愿使用与客户端相同的版本。响应中应当包含一个描述了为何版本不被支持以及服务器支持哪些协议的实体\r\n    VARIANT_ALSO_NEGOTIATES: 506,  //服务器存在内部配置错误:被请求的协商变元资源被配置为在透明内容协商中使用自己,因此在一个协商处理中不是一个合适的重点\r\n    INSUFFICIENT_STORAGE: 507,  //服务器无法存储完成请求所必须的内容。这个状况被认为是临时的\r\n    BANDWIDTH_LIMIT_EXCEEDED: 509,  //服务器达到带宽限制。这不是一个官方的状态码,但是仍被广泛使用\r\n    NOT_EXTENDED: 510  //获取资源所需要的策略并没有没满足\r\n\r\n};","import path from 'path';\r\n\r\nimport fs from 'fs-extra';\r\nimport yaml from 'yaml';\r\nimport _ from 'lodash';\r\n\r\nimport environment from '../environment.ts';\r\n\r\nconst CONFIG_PATH = path.join(path.resolve(), 'configs/', environment.env, \"/system.yml\");\r\n\r\n/**\r\n * 系统配置\r\n */\r\nexport class SystemConfig {\r\n\r\n    /** 是否开启请求日志 */\r\n    requestLog: boolean;\r\n    /** 临时目录路径 */\r\n    tmpDir: string;\r\n    /** 日志目录路径 */\r\n    logDir: string;\r\n    /** 日志写入间隔(毫秒) */\r\n    logWriteInterval: number;\r\n    /** 日志文件有效期(毫秒) */\r\n    logFileExpires: number;\r\n    /** 公共目录路径 */\r\n    publicDir: string;\r\n    /** 临时文件有效期(毫秒) */\r\n    tmpFileExpires: number;\r\n    /** 请求体配置 */\r\n    requestBody: any;\r\n    /** 是否调试模式 */\r\n    debug: boolean;\r\n\r\n    constructor(options?: any) {\r\n        const { requestLog, tmpDir, logDir, logWriteInterval, logFileExpires, publicDir, tmpFileExpires, requestBody, debug } = options || {};\r\n        this.requestLog = _.defaultTo(requestLog, false);\r\n        this.tmpDir = _.defaultTo(tmpDir, './tmp');\r\n        this.logDir = _.defaultTo(logDir, './logs');\r\n        this.logWriteInterval = _.defaultTo(logWriteInterval, 200);\r\n        this.logFileExpires = _.defaultTo(logFileExpires, 2626560000);\r\n        this.publicDir = _.defaultTo(publicDir, './public');\r\n        this.tmpFileExpires = _.defaultTo(tmpFileExpires, 86400000);\r\n        this.requestBody = Object.assign(requestBody || {}, {\r\n            enableTypes: ['json', 'form', 'text', 'xml'],\r\n            encoding: 'utf-8',\r\n            formLimit: '100mb',\r\n            jsonLimit: '100mb',\r\n            textLimit: '100mb',\r\n            xmlLimit: '100mb',\r\n            formidable: {\r\n                maxFileSize: '100mb'\r\n            },\r\n            multipart: true,\r\n            parsedMethods: ['POST', 'PUT', 'PATCH']\r\n        });\r\n        this.debug = _.defaultTo(debug, true);\r\n    }\r\n\r\n    get rootDirPath() {\r\n        return path.resolve();\r\n    }\r\n\r\n    get tmpDirPath() {\r\n        return path.resolve(this.tmpDir);\r\n    }\r\n\r\n    get logDirPath() {\r\n        return path.resolve(this.logDir);\r\n    }\r\n\r\n    get publicDirPath() {\r\n        return path.resolve(this.publicDir);\r\n    }\r\n\r\n    static load() {\r\n        if (!fs.pathExistsSync(CONFIG_PATH)) return new SystemConfig();\r\n        const data = yaml.parse(fs.readFileSync(CONFIG_PATH).toString());\r\n        return new SystemConfig(data);\r\n    }\r\n\r\n}\r\n\r\nexport default SystemConfig.load();","import serviceConfig from \"./configs/service-config.ts\";\r\nimport systemConfig from \"./configs/system-config.ts\";\r\n\r\nclass Config {\r\n    \r\n    /** 服务配置 */\r\n    service = serviceConfig;\r\n    \r\n    /** 系统配置 */\r\n    system = systemConfig;\r\n\r\n}\r\n\r\nexport default new Config();","import path from 'path';\r\nimport _util from 'util';\r\n\r\nimport 'colors';\r\nimport _ from 'lodash';\r\nimport fs from 'fs-extra';\r\nimport { format as dateFormat } from 'date-fns';\r\n\r\nimport config from './config.ts';\r\nimport util from './util.ts';\r\n\r\nconst isVercelEnv = process.env.VERCEL;\r\n\r\nclass LogWriter {\r\n\r\n    #buffers = [];\r\n\r\n    constructor() {\r\n        !isVercelEnv && fs.ensureDirSync(config.system.logDirPath);\r\n        !isVercelEnv && this.work();\r\n    }\r\n\r\n    push(content) {\r\n        const buffer = Buffer.from(content);\r\n        this.#buffers.push(buffer);\r\n    }\r\n\r\n    writeSync(buffer) {\r\n        !isVercelEnv && fs.appendFileSync(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), buffer);\r\n    }\r\n\r\n    async write(buffer) {\r\n        !isVercelEnv && await fs.appendFile(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), buffer);\r\n    }\r\n\r\n    flush() {\r\n        if(!this.#buffers.length) return;\r\n        !isVercelEnv && fs.appendFileSync(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), Buffer.concat(this.#buffers));\r\n    }\r\n\r\n    work() {\r\n        if (!this.#buffers.length) return setTimeout(this.work.bind(this), config.system.logWriteInterval);\r\n        const buffer = Buffer.concat(this.#buffers);\r\n        this.#buffers = [];\r\n        this.write(buffer)\r\n        .finally(() => setTimeout(this.work.bind(this), config.system.logWriteInterval))\r\n        .catch(err => console.error(\"Log write error:\", err));\r\n    }\r\n\r\n}\r\n\r\nclass LogText {\r\n\r\n    /** @type {string} 日志级别 */\r\n    level;\r\n    /** @type {string} 日志文本 */\r\n    text;\r\n    /** @type {string} 日志来源 */\r\n    source;\r\n    /** @type {Date} 日志发生时间 */\r\n    time = new Date();\r\n\r\n    constructor(level, ...params) {\r\n        this.level = level;\r\n        this.text = _util.format.apply(null, params);\r\n        this.source = this.#getStackTopCodeInfo();\r\n    }\r\n\r\n    #getStackTopCodeInfo() {\r\n        const unknownInfo = { name: \"unknown\", codeLine: 0, codeColumn: 0 };\r\n        const stackArray = new Error().stack.split(\"\\n\");\r\n        const text = stackArray[4];\r\n        if (!text)\r\n            return unknownInfo;\r\n        const match = text.match(/at (.+) \\((.+)\\)/) || text.match(/at (.+)/);\r\n        if (!match || !_.isString(match[2] || match[1]))\r\n            return unknownInfo;\r\n        const temp = match[2] || match[1];\r\n        const _match = temp.match(/([a-zA-Z0-9_\\-\\.]+)\\:(\\d+)\\:(\\d+)$/);\r\n        if (!_match)\r\n            return unknownInfo;\r\n        const [, scriptPath, codeLine, codeColumn] = _match as any;\r\n        return {\r\n            name: scriptPath ? scriptPath.replace(/.js$/, \"\") : \"unknown\",\r\n            path: scriptPath || null,\r\n            codeLine: parseInt(codeLine || 0),\r\n            codeColumn: parseInt(codeColumn || 0)\r\n        };\r\n    }\r\n\r\n    toString() {\r\n        return `[${dateFormat(this.time, \"yyyy-MM-dd HH:mm:ss.SSS\")}][${this.level}][${this.source.name}<${this.source.codeLine},${this.source.codeColumn}>] ${this.text}`;\r\n    }\r\n\r\n}\r\n\r\nclass Logger {\r\n\r\n    /** @type {Object} 系统配置 */\r\n    config = {};\r\n    /** @type {Object} 日志级别映射 */\r\n    static Level = {\r\n        Success: \"success\",\r\n        Info: \"info\",\r\n        Log: \"log\",\r\n        Debug: \"debug\",\r\n        Warning: \"warning\",\r\n        Error: \"error\",\r\n        Fatal: \"fatal\"\r\n    };\r\n    /** @type {Object} 日志级别文本颜色樱色 */\r\n    static LevelColor = {\r\n        [Logger.Level.Success]: \"green\",\r\n        [Logger.Level.Info]: \"brightCyan\",\r\n        [Logger.Level.Debug]: \"white\",\r\n        [Logger.Level.Warning]: \"brightYellow\",\r\n        [Logger.Level.Error]: \"brightRed\",\r\n        [Logger.Level.Fatal]: \"red\"\r\n    };\r\n    #writer;\r\n\r\n    constructor() {\r\n        this.#writer = new LogWriter();\r\n    }\r\n\r\n    header() {\r\n        this.#writer.writeSync(Buffer.from(`\\n\\n===================== LOG START ${dateFormat(new Date(), \"yyyy-MM-dd HH:mm:ss.SSS\")} =====================\\n\\n`));\r\n    }\r\n\r\n    footer() {\r\n        this.#writer.flush();  //将未写入文件的日志缓存写入\r\n        this.#writer.writeSync(Buffer.from(`\\n\\n===================== LOG END ${dateFormat(new Date(), \"yyyy-MM-dd HH:mm:ss.SSS\")} =====================\\n\\n`));\r\n    }\r\n\r\n    success(...params) {\r\n        const content = new LogText(Logger.Level.Success, ...params).toString();\r\n        console.info(content[Logger.LevelColor[Logger.Level.Success]]);\r\n        this.#writer.push(content + \"\\n\");\r\n    }\r\n\r\n    info(...params) {\r\n        const content = new LogText(Logger.Level.Info, ...params).toString();\r\n        console.info(content[Logger.LevelColor[Logger.Level.Info]]);\r\n        this.#writer.push(content + \"\\n\");\r\n    }\r\n\r\n    log(...params) {\r\n        const content = new LogText(Logger.Level.Log, ...params).toString();\r\n        console.log(content[Logger.LevelColor[Logger.Level.Log]]);\r\n        this.#writer.push(content + \"\\n\");\r\n    }\r\n\r\n    debug(...params) {\r\n        if(!config.system.debug) return;  //非调试模式忽略debug\r\n        const content = new LogText(Logger.Level.Debug, ...params).toString();\r\n        console.debug(content[Logger.LevelColor[Logger.Level.Debug]]);\r\n        this.#writer.push(content + \"\\n\");\r\n    }\r\n\r\n    warn(...params) {\r\n        const content = new LogText(Logger.Level.Warning, ...params).toString();\r\n        console.warn(content[Logger.LevelColor[Logger.Level.Warning]]);\r\n        this.#writer.push(content + \"\\n\");\r\n    }\r\n\r\n    error(...params) {\r\n        const content = new LogText(Logger.Level.Error, ...params).toString();\r\n        console.error(content[Logger.LevelColor[Logger.Level.Error]]);\r\n        this.#writer.push(content);\r\n    }\r\n\r\n    fatal(...params) {\r\n        const content = new LogText(Logger.Level.Fatal, ...params).toString();\r\n        console.error(content[Logger.LevelColor[Logger.Level.Fatal]]);\r\n        this.#writer.push(content);\r\n    }\r\n\r\n    destory() {\r\n        this.#writer.destory();\r\n    }\r\n\r\n}\r\n\r\nexport default new Logger();","import logger from './logger.js';\r\n\r\n// 允许无限量的监听器\r\nprocess.setMaxListeners(Infinity);\r\n// 输出未捕获异常\r\nprocess.on(\"uncaughtException\", (err, origin) => {\r\n    logger.error(`An unhandled error occurred: ${origin}`, err);\r\n});\r\n// 输出未处理的Promise.reject\r\nprocess.on(\"unhandledRejection\", (_, promise) => {\r\n    promise.catch(err => logger.error(\"An unhandled rejection occurred:\", err));\r\n});\r\n// 输出系统警告信息\r\nprocess.on(\"warning\", warning => logger.warn(\"System warning: \", warning));\r\n// 进程退出监听\r\nprocess.on(\"exit\", () => {\r\n    logger.info(\"Service exit\");\r\n    logger.footer();\r\n});\r\n// 进程被kill\r\nprocess.on(\"SIGTERM\", () => {\r\n    logger.warn(\"received kill signal\");\r\n    process.exit(2);\r\n});\r\n// Ctrl-C进程退出\r\nprocess.on(\"SIGINT\", () => {\r\n    process.exit(0);\r\n});","import Koa from 'koa';\r\nimport KoaRouter from 'koa-router';\r\nimport koaRange from 'koa-range';\r\nimport koaCors from \"koa2-cors\";\r\nimport koaBody from 'koa-body';\r\nimport _ from 'lodash';\r\n\r\nimport Exception from './exceptions/Exception.ts';\r\nimport Request from './request/Request.ts';\r\nimport Response from './response/Response.js';\r\nimport FailureBody from './response/FailureBody.ts';\r\nimport EX from './consts/exceptions.ts';\r\nimport logger from './logger.ts';\r\nimport config from './config.ts';\r\n\r\nclass Server {\r\n\r\n    app;\r\n    router;\r\n    \r\n    constructor() {\r\n        this.app = new Koa();\r\n        this.app.use(koaCors());\r\n        // 范围请求支持\r\n        this.app.use(koaRange);\r\n        this.router = new KoaRouter({ prefix: config.service.urlPrefix });\r\n        // 前置处理异常拦截\r\n        this.app.use(async (ctx: any, next: Function) => {\r\n            if(ctx.request.type === \"application/xml\" || ctx.request.type === \"application/ssml+xml\")\r\n                ctx.req.headers[\"content-type\"] = \"text/xml\";\r\n            try { await next() }\r\n            catch (err) {\r\n                logger.error(err);\r\n                const failureBody = new FailureBody(err);\r\n                new Response(failureBody).injectTo(ctx);\r\n            }\r\n        });\r\n        // 载荷解析器支持\r\n        this.app.use(koaBody(_.clone(config.system.requestBody)));\r\n        this.app.on(\"error\", (err: any) => {\r\n            // 忽略连接重试、中断、管道、取消错误\r\n            if ([\"ECONNRESET\", \"ECONNABORTED\", \"EPIPE\", \"ECANCELED\"].includes(err.code)) return;\r\n            logger.error(err);\r\n        });\r\n        logger.success(\"Server initialized\");\r\n    }\r\n\r\n    /**\r\n     * 附加路由\r\n     * \r\n     * @param routes 路由列表\r\n     */\r\n    attachRoutes(routes: any[]) {\r\n        routes.forEach((route: any) => {\r\n            const prefix = route.prefix || \"\";\r\n            for (let method in route) {\r\n                if(method === \"prefix\") continue;\r\n                if (!_.isObject(route[method])) {\r\n                    logger.warn(`Router ${prefix} ${method} invalid`);\r\n                    continue;\r\n                }\r\n                for (let uri in route[method]) {\r\n                    this.router[method](`${prefix}${uri}`, async ctx => {\r\n                        const { request, response } = await this.#requestProcessing(ctx, route[method][uri]);\r\n                        if(response != null && config.system.requestLog)\r\n                            logger.info(`<- ${request.method} ${request.url} ${response.time - request.time}ms`);\r\n                    });\r\n                }\r\n            }\r\n            logger.info(`Route ${config.service.urlPrefix || \"\"}${prefix} attached`);\r\n        });\r\n        this.app.use(this.router.routes());\r\n        this.app.use((ctx: any) => {\r\n            const request = new Request(ctx);\r\n            logger.debug(`-> ${ctx.request.method} ${ctx.request.url} request is not supported - ${request.remoteIP || \"unknown\"}`);\r\n            // const failureBody = new FailureBody(new Exception(EX.SYSTEM_NOT_ROUTE_MATCHING, \"Request is not supported\"));\r\n            // const response = new Response(failureBody);\r\n            const message = `[请求有误]: 正确请求为 POST -> /v1/chat/completions,当前请求为 ${ctx.request.method} -> ${ctx.request.url} 请纠正`;\r\n            logger.warn(message);\r\n            const failureBody = new FailureBody(new Error(message));\r\n            const response = new Response(failureBody);\r\n            response.injectTo(ctx);\r\n            if(config.system.requestLog)\r\n                logger.info(`<- ${request.method} ${request.url} ${response.time - request.time}ms`);\r\n        });\r\n    }\r\n\r\n    /**\r\n     * 请求处理\r\n     * \r\n     * @param ctx 上下文\r\n     * @param routeFn 路由方法\r\n     */\r\n    #requestProcessing(ctx: any, routeFn: Function): Promise<any> {\r\n        return new Promise(resolve => {\r\n            const request = new Request(ctx);\r\n            try {\r\n                if(config.system.requestLog)\r\n                    logger.info(`-> ${request.method} ${request.url}`);\r\n                    routeFn(request)\r\n                .then(response => {\r\n                    try {\r\n                        if(!Response.isInstance(response)) {\r\n                            const _response = new Response(response);\r\n                            _response.injectTo(ctx);\r\n                            return resolve({ request, response: _response });\r\n                        }\r\n                        response.injectTo(ctx);\r\n                        resolve({ request, response });\r\n                    }\r\n                    catch(err) {\r\n                        logger.error(err);\r\n                        const failureBody = new FailureBody(err);\r\n                        const response = new Response(failureBody);\r\n                        response.injectTo(ctx);\r\n                        resolve({ request, response });\r\n                    }\r\n                })\r\n                .catch(err => {\r\n                    try {\r\n                        logger.error(err);\r\n                        const failureBody = new FailureBody(err);\r\n                        const response = new Response(failureBody);\r\n                        response.injectTo(ctx);\r\n                        resolve({ request, response });\r\n                    }\r\n                    catch(err) {\r\n                        logger.error(err);\r\n                        const failureBody = new FailureBody(err);\r\n                        const response = new Response(failureBody);\r\n                        response.injectTo(ctx);\r\n                        resolve({ request, response });\r\n                    }\r\n                });\r\n            }\r\n            catch(err) {\r\n                logger.error(err);\r\n                const failureBody = new FailureBody(err);\r\n                const response = new Response(failureBody);\r\n                response.injectTo(ctx);\r\n                resolve({ request, response });\r\n            }\r\n        });\r\n    }\r\n\r\n    /**\r\n     * 监听端口\r\n     */\r\n    async listen() {\r\n        const host = config.service.host;\r\n        const port = config.service.port;\r\n        await Promise.all([\r\n            new Promise((resolve, reject) => {\r\n                if(host === \"0.0.0.0\" || host === \"localhost\" || host === \"127.0.0.1\")\r\n                    return resolve(null);\r\n                this.app.listen(port, \"localhost\", err => {\r\n                    if(err) return reject(err);\r\n                    resolve(null);\r\n                });\r\n            }),\r\n            new Promise((resolve, reject) => {\r\n                this.app.listen(port, host, err => {\r\n                    if(err) return reject(err);\r\n                    resolve(null);\r\n                });\r\n            })\r\n        ]);\r\n        logger.success(`Server listening on port ${port} (${host})`);\r\n    }\r\n\r\n}\r\n\r\nexport default new Server();","import _ from 'lodash';\r\n\r\nimport APIException from '@/lib/exceptions/APIException.ts';\r\nimport EX from '@/api/consts/exceptions.ts';\r\nimport logger from '@/lib/logger.ts';\r\nimport util from '@/lib/util.ts';\r\n\r\nexport interface RequestOptions {\r\n    time?: number;\r\n}\r\n\r\nexport default class Request {\r\n\r\n    /** 请求方法 */\r\n    method: string;\r\n    /** 请求URL */\r\n    url: string;\r\n    /** 请求路径 */\r\n    path: string;\r\n    /** 请求载荷类型 */\r\n    type: string;\r\n    /** 请求headers */\r\n    headers: any;\r\n    /** 请求原始查询字符串 */\r\n    search: string;\r\n    /** 请求查询参数 */\r\n    query: any;\r\n    /** 请求URL参数 */\r\n    params: any;\r\n    /** 请求载荷 */\r\n    body: any;\r\n    /** 上传的文件 */\r\n    files: any[];\r\n    /** 客户端IP地址 */\r\n    remoteIP: string | null;\r\n    /** 请求接受时间戳(毫秒) */\r\n    time: number;\r\n\r\n    constructor(ctx, options: RequestOptions = {}) {\r\n        const { time } = options;\r\n        this.method = ctx.request.method;\r\n        this.url = ctx.request.url;\r\n        this.path = ctx.request.path;\r\n        this.type = ctx.request.type;\r\n        this.headers = ctx.request.headers || {};\r\n        this.search = ctx.request.search;\r\n        this.query = ctx.query || {};\r\n        this.params = ctx.params || {};\r\n        this.body = ctx.request.body || {};\r\n        this.files = ctx.request.files || {};\r\n        this.remoteIP = this.headers[\"X-Real-IP\"] || this.headers[\"x-real-ip\"] || this.headers[\"X-Forwarded-For\"] || this.headers[\"x-forwarded-for\"] || ctx.ip || null;\r\n        this.time = Number(_.defaultTo(time, util.timestamp()));\r\n    }\r\n\r\n    validate(key: string, fn?: Function) {\r\n        try {\r\n            const value = _.get(this, key);\r\n            if (fn) {\r\n                if (fn(value) === false)\r\n                    throw `[Mismatch] -> ${fn}`;\r\n            }\r\n            else if (_.isUndefined(value))\r\n                throw '[Undefined]';\r\n        }\r\n        catch (err) {\r\n            logger.warn(`Params ${key} invalid:`, err);\r\n            throw new APIException(EX.API_REQUEST_PARAMS_INVALID, `Params ${key} invalid`);\r\n        }\r\n        return this;\r\n    }\r\n\r\n}","import assert from 'assert';\r\n\r\nimport _ from 'lodash';\r\n\r\nexport default class Exception extends Error {\r\n\r\n    /** 错误码 */\r\n    errcode: number;\r\n    /** 错误消息 */\r\n    errmsg: string;\r\n    /** 数据 */\r\n    data: any;\r\n    /** HTTP状态码 */\r\n    httpStatusCode: number;\r\n\r\n    /**\r\n     * 构造异常\r\n     * \r\n     * @param exception 异常\r\n     * @param _errmsg 异常消息\r\n     */\r\n    constructor(exception: (string | number)[], _errmsg?: string) {\r\n        assert(_.isArray(exception), 'Exception must be Array');\r\n        const [errcode, errmsg] = exception as [number, string];\r\n        assert(_.isFinite(errcode), 'Exception errcode invalid');\r\n        assert(_.isString(errmsg), 'Exception errmsg invalid');\r\n        super(_errmsg || errmsg);\r\n        this.errcode = errcode;\r\n        this.errmsg = _errmsg || errmsg;\r\n    }\r\n\r\n    compare(exception: (string | number)[]) {\r\n        const [errcode] = exception as [number, string];\r\n        return this.errcode == errcode;\r\n    }\r\n\r\n    setHTTPStatusCode(value: number) {\r\n        this.httpStatusCode = value;\r\n        return this;\r\n    }\r\n\r\n    setData(value: any) {\r\n        this.data = _.defaultTo(value, null);\r\n        return this;\r\n    }\r\n\r\n}","import Exception from './Exception.js';\r\n\r\nexport default class APIException extends Exception {\r\n\r\n    /**\r\n     * 构造异常\r\n     * \r\n     * @param {[number, string]} exception 异常\r\n     */\r\n    constructor(exception: (string | number)[], errmsg?: string) {\r\n        super(exception, errmsg);\r\n    }\r\n\r\n}","export default {\r\n    API_TEST: [-9999, 'API异常错误'],\r\n    API_REQUEST_PARAMS_INVALID: [-2000, '请求参数非法'],\r\n    API_REQUEST_FAILED: [-2001, '请求失败'],\r\n    API_TOKEN_EXPIRES: [-2002, 'Token已失效'],\r\n    API_FILE_URL_INVALID: [-2003, '远程文件URL非法'],\r\n    API_FILE_EXECEEDS_SIZE: [-2004, '远程文件超出大小'],\r\n    API_CHAT_STREAM_PUSHING: [-2005, '已有对话流正在输出'],\r\n    API_CONTENT_FILTERED: [-2006, '内容由于合规问题已被阻止生成'],\r\n    API_IMAGE_GENERATION_FAILED: [-2007, '图像生成失败']\r\n}","import mime from 'mime';\r\nimport _ from 'lodash';\r\n\r\nimport Body from './Body.ts';\r\nimport util from '../util.ts';\r\n\r\nexport interface ResponseOptions {\r\n    statusCode?: number;\r\n    type?: string;\r\n    headers?: Record<string, any>;\r\n    redirect?: string;\r\n    body?: any;\r\n    size?: number;\r\n    time?: number;\r\n}\r\n\r\nexport default class Response {\r\n\r\n    /** 响应HTTP状态码 */\r\n    statusCode: number;\r\n    /** 响应内容类型 */\r\n    type: string;\r\n    /** 响应headers */\r\n    headers: Record<string, any>;\r\n    /** 重定向目标 */\r\n    redirect: string;\r\n    /** 响应载荷 */\r\n    body: any;\r\n    /** 响应载荷大小 */\r\n    size: number;\r\n    /** 响应时间戳 */\r\n    time: number;\r\n\r\n    constructor(body: any, options: ResponseOptions = {}) {\r\n        const { statusCode, type, headers, redirect, size, time } = options;\r\n        this.statusCode = Number(_.defaultTo(statusCode, Body.isInstance(body) ? body.statusCode : undefined))\r\n        this.type = type;\r\n        this.headers = headers;\r\n        this.redirect = redirect;\r\n        this.size = size;\r\n        this.time = Number(_.defaultTo(time, util.timestamp()));\r\n        this.body = body;\r\n    }\r\n\r\n    injectTo(ctx) {\r\n        this.redirect && ctx.redirect(this.redirect);\r\n        this.statusCode && (ctx.status = this.statusCode);\r\n        this.type && (ctx.type = mime.getType(this.type) || this.type);\r\n        const headers = this.headers || {};\r\n        if(this.size && !headers[\"Content-Length\"] && !headers[\"content-length\"])\r\n            headers[\"Content-Length\"] = this.size;\r\n        ctx.set(headers);\r\n        if(Body.isInstance(this.body))\r\n            ctx.body = this.body.toObject();\r\n        else\r\n            ctx.body = this.body;\r\n    }\r\n\r\n    static isInstance(value) {\r\n        return value instanceof Response;\r\n    }\r\n\r\n}","import  _ from 'lodash';\r\n\r\nexport interface BodyOptions {\r\n    code?: number;\r\n    message?: string;\r\n    data?: any;\r\n    statusCode?: number;\r\n}\r\n\r\nexport default class Body {\r\n\r\n    /** 状态码 */\r\n    code: number;\r\n    /** 状态消息 */\r\n    message: string;\r\n    /** 载荷 */\r\n    data: any;\r\n    /** HTTP状态码 */\r\n    statusCode: number;\r\n\r\n    constructor(options: BodyOptions = {}) {\r\n        const { code, message, data, statusCode } = options;\r\n        this.code = Number(_.defaultTo(code, 0));\r\n        this.message = _.defaultTo(message, 'OK');\r\n        this.data = _.defaultTo(data, null);\r\n        this.statusCode = Number(_.defaultTo(statusCode, 200));\r\n    }\r\n\r\n    toObject() {\r\n        return {\r\n            code: this.code,\r\n            message: this.message,\r\n            data: this.data\r\n        };\r\n    }\r\n\r\n    static isInstance(value) {\r\n        return value instanceof Body;\r\n    }\r\n\r\n}","import _ from 'lodash';\r\n\r\nimport Body from './Body.ts';\r\nimport Exception from '../exceptions/Exception.ts';\r\nimport APIException from '../exceptions/APIException.ts';\r\nimport EX from '../consts/exceptions.ts';\r\nimport HTTP_STATUS_CODES from '../http-status-codes.ts';\r\n\r\nexport default class FailureBody extends Body {\r\n    \r\n    constructor(error: APIException | Exception | Error, _data?: any) {\r\n        let errcode, errmsg, data = _data, httpStatusCode = HTTP_STATUS_CODES.OK;;\r\n        if(_.isString(error))\r\n            error = new Exception(EX.SYSTEM_ERROR, error);\r\n        else if(error instanceof APIException || error instanceof Exception)\r\n            ({ errcode, errmsg, data, httpStatusCode } = error);\r\n        else if(_.isError(error))\r\n        ({ errcode, errmsg, data, httpStatusCode } = new Exception(EX.SYSTEM_ERROR, error.message));\r\n        super({\r\n            code: errcode || -1,\r\n            message: errmsg || 'Internal error',\r\n            data,\r\n            statusCode: httpStatusCode\r\n        });\r\n    }\r\n\r\n    static isInstance(value) {\r\n        return value instanceof FailureBody;\r\n    }\r\n\r\n}","export default {\r\n    SYSTEM_ERROR: [-1000, '系统异常'],\r\n    SYSTEM_REQUEST_VALIDATION_ERROR: [-1001, '请求参数校验错误'],\r\n    SYSTEM_NOT_ROUTE_MATCHING: [-1002, '无匹配的路由']\r\n} as Record<string, [number, string]>","import fs from 'fs-extra';\r\n\r\nimport Response from '@/lib/response/Response.ts';\r\nimport chat from \"./chat.ts\";\r\nimport ping from \"./ping.ts\";\r\nimport token from './token.js';\r\nimport models from './models.ts';\r\n\r\nexport default [\r\n    {\r\n        get: {\r\n            '/': async () => {\r\n                const content = await fs.readFile('public/welcome.html');\r\n                return new Response(content, {\r\n                    type: 'html',\r\n                    headers: {\r\n                        Expires: '-1'\r\n                    }\r\n                });\r\n            }\r\n        }\r\n    },\r\n    chat,\r\n    ping,\r\n    token,\r\n    models\r\n];","import _ from 'lodash';\r\n\r\nimport Request from '@/lib/request/Request.ts';\r\nimport Response from '@/lib/response/Response.ts';\r\nimport chat from '@/api/controllers/chat.ts';\r\n\r\nexport default {\r\n\r\n    prefix: '/v1/chat',\r\n\r\n    post: {\r\n\r\n        '/completions': async (request: Request) => {\r\n            request\r\n                .validate('body.conversation_id', v => _.isUndefined(v) || _.isString(v))\r\n                .validate('body.messages', _.isArray)\r\n                .validate('headers.authorization', _.isString)\r\n            // token切分\r\n            const tokens = chat.tokenSplit(request.headers.authorization);\r\n            // 随机挑选一个token\r\n            const token = _.sample(tokens);\r\n            let { model, messages, stream } = request.body;\r\n            if(['deepseek_chat', 'deepseek_code', 'deepseek-chat*', 'deepseek-chat', 'deepseek-coder'].includes(model))\r\n                model = {\r\n                    'deepseek-chat*': 'deepseek_chat',\r\n                    'deepseek-chat': 'deepseek_chat',\r\n                    'deepseek-coder': 'deepseek_code'\r\n                }[model] || model;\r\n            else\r\n                model = 'deepseek_chat';\r\n            if (stream) {\r\n                const stream = await chat.createCompletionStream(model, messages, token);\r\n                return new Response(stream, {\r\n                    type: \"text/event-stream\"\r\n                });\r\n            }\r\n            else\r\n                return await chat.createCompletion(model, messages, token);\r\n        }\r\n\r\n    }\r\n\r\n}","import { PassThrough } from \"stream\";\r\nimport _ from \"lodash\";\r\nimport AsyncLock from \"async-lock\";\r\nimport axios, { AxiosResponse } from \"axios\";\r\n\r\nimport APIException from \"@/lib/exceptions/APIException.ts\";\r\nimport EX from \"@/api/consts/exceptions.ts\";\r\nimport { createParser } from \"eventsource-parser\";\r\nimport logger from \"@/lib/logger.ts\";\r\nimport util from \"@/lib/util.ts\";\r\n\r\n// 模型名称\r\nconst MODEL_NAME = \"deepseek-chat\";\r\n// access_token有效期\r\nconst ACCESS_TOKEN_EXPIRES = 3600;\r\n// 最大重试次数\r\nconst MAX_RETRY_COUNT = 3;\r\n// 重试延迟\r\nconst RETRY_DELAY = 5000;\r\n// 伪装headers\r\nconst FAKE_HEADERS = {\r\n  Accept: \"*/*\",\r\n  \"Accept-Encoding\": \"gzip, deflate, br, zstd\",\r\n  \"Accept-Language\": \"zh-CN,zh;q=0.9\",\r\n  Origin: \"https://chat.deepseek.com\",\r\n  Pragma: \"no-cache\",\r\n  Referer: \"https://chat.deepseek.com/\",\r\n  \"Sec-Ch-Ua\":\r\n    '\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"',\r\n  \"Sec-Ch-Ua-Mobile\": \"?0\",\r\n  \"Sec-Ch-Ua-Platform\": '\"Windows\"',\r\n  \"Sec-Fetch-Dest\": \"empty\",\r\n  \"Sec-Fetch-Mode\": \"cors\",\r\n  \"Sec-Fetch-Site\": \"same-origin\",\r\n  \"User-Agent\":\r\n    \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36\",\r\n  \"X-App-Version\": \"20240126.0\",\r\n};\r\n// access_token映射\r\nconst accessTokenMap = new Map();\r\n// access_token请求队列映射\r\nconst accessTokenRequestQueueMap: Record<string, Function[]> = {};\r\n\r\n// 聊天异步锁\r\nconst chatLock = new AsyncLock();\r\n\r\n/**\r\n * 请求access_token\r\n *\r\n * 使用refresh_token去刷新获得access_token\r\n *\r\n * @param refreshToken 用于刷新access_token的refresh_token\r\n */\r\nasync function requestToken(refreshToken: string) {\r\n  if (accessTokenRequestQueueMap[refreshToken])\r\n    return new Promise((resolve) =>\r\n      accessTokenRequestQueueMap[refreshToken].push(resolve)\r\n    );\r\n  accessTokenRequestQueueMap[refreshToken] = [];\r\n  logger.info(`Refresh token: ${refreshToken}`);\r\n  const result = await (async () => {\r\n    const result = await axios.get(\r\n      \"https://chat.deepseek.com/api/v0/users/current\",\r\n      {\r\n        headers: {\r\n          Authorization: `Bearer ${refreshToken}`,\r\n          ...FAKE_HEADERS,\r\n        },\r\n        timeout: 15000,\r\n        validateStatus: () => true,\r\n      }\r\n    );\r\n    const { token } = checkResult(result, refreshToken);\r\n    return {\r\n      accessToken: token,\r\n      refreshToken: token,\r\n      refreshTime: util.unixTimestamp() + ACCESS_TOKEN_EXPIRES,\r\n    };\r\n  })()\r\n    .then((result) => {\r\n      if (accessTokenRequestQueueMap[refreshToken]) {\r\n        accessTokenRequestQueueMap[refreshToken].forEach((resolve) =>\r\n          resolve(result)\r\n        );\r\n        delete accessTokenRequestQueueMap[refreshToken];\r\n      }\r\n      logger.success(`Refresh successful`);\r\n      return result;\r\n    })\r\n    .catch((err) => {\r\n      if (accessTokenRequestQueueMap[refreshToken]) {\r\n        accessTokenRequestQueueMap[refreshToken].forEach((resolve) =>\r\n          resolve(err)\r\n        );\r\n        delete accessTokenRequestQueueMap[refreshToken];\r\n      }\r\n      return err;\r\n    });\r\n  if (_.isError(result)) throw result;\r\n  return result;\r\n}\r\n\r\n/**\r\n * 获取缓存中的access_token\r\n *\r\n * 避免短时间大量刷新token,未加锁,如果有并发要求还需加锁\r\n *\r\n * @param refreshToken 用于刷新access_token的refresh_token\r\n */\r\nasync function acquireToken(refreshToken: string): Promise<string> {\r\n  let result = accessTokenMap.get(refreshToken);\r\n  if (!result) {\r\n    result = await requestToken(refreshToken);\r\n    accessTokenMap.set(refreshToken, result);\r\n  }\r\n  if (util.unixTimestamp() > result.refreshTime) {\r\n    result = await requestToken(refreshToken);\r\n    accessTokenMap.set(refreshToken, result);\r\n  }\r\n  return result.accessToken;\r\n}\r\n\r\n/**\r\n * 清除上下文\r\n *\r\n * @param model 模型名称\r\n * @param refreshToken 用于刷新access_token的refresh_token\r\n */\r\nasync function clearContext(model: string, refreshToken: string) {\r\n  const token = await acquireToken(refreshToken);\r\n  const result = await axios.post(\r\n    \"https://chat.deepseek.com/api/v0/chat/clear_context\",\r\n    {\r\n      model_class: model,\r\n      append_welcome_message: false\r\n    },\r\n    {\r\n      headers: {\r\n        Authorization: `Bearer ${token}`,\r\n        ...FAKE_HEADERS,\r\n      },\r\n      timeout: 15000,\r\n      validateStatus: () => true,\r\n    }\r\n  );\r\n  checkResult(result, refreshToken);\r\n}\r\n\r\n/**\r\n * 同步对话补全\r\n *\r\n * @param model 模型名称\r\n * @param messages 参考gpt系列消息格式,多轮对话请完整提供上下文\r\n * @param refreshToken 用于刷新access_token的refresh_token\r\n * @param retryCount 重试次数\r\n */\r\nasync function createCompletion(\r\n  model = MODEL_NAME,\r\n  messages: any[],\r\n  refreshToken: string,\r\n  retryCount = 0\r\n) {\r\n  return (async () => {\r\n    logger.info(messages);\r\n\r\n    // 确保当前请求有干净上下文\r\n    const result = await chatLock.acquire(refreshToken, async () => {\r\n      // 清除上下文\r\n      await clearContext(model, refreshToken);\r\n      // 请求流\r\n      const token = await acquireToken(refreshToken);\r\n      return await axios.post(\r\n        \"https://chat.deepseek.com/api/v0/chat/completions\",\r\n        {\r\n          message: messagesPrepare(messages),\r\n          stream: true,\r\n          model_preference: null,\r\n          model_class: model,\r\n          temperature: 0\r\n        },\r\n        {\r\n          headers: {\r\n            Authorization: `Bearer ${token}`,\r\n            ...FAKE_HEADERS\r\n          },\r\n          // 120秒超时\r\n          timeout: 120000,\r\n          validateStatus: () => true,\r\n          responseType: \"stream\",\r\n        }\r\n      );\r\n    });\r\n\r\n    if (result.headers[\"content-type\"].indexOf(\"text/event-stream\") == -1) {\r\n      result.data.on(\"data\", buffer => logger.error(buffer.toString()));\r\n      throw new APIException(\r\n        EX.API_REQUEST_FAILED,\r\n        `Stream response Content-Type invalid: ${result.headers[\"content-type\"]}`\r\n      );\r\n    }\r\n\r\n    const streamStartTime = util.timestamp();\r\n    // 接收流为输出文本\r\n    const answer = await receiveStream(model, result.data);\r\n    logger.success(\r\n      `Stream has completed transfer ${util.timestamp() - streamStartTime}ms`\r\n    );\r\n\r\n    return answer;\r\n  })().catch((err) => {\r\n    if (retryCount < MAX_RETRY_COUNT) {\r\n      logger.error(`Stream response error: ${err.stack}`);\r\n      logger.warn(`Try again after ${RETRY_DELAY / 1000}s...`);\r\n      return (async () => {\r\n        await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));\r\n        return createCompletion(\r\n          model,\r\n          messages,\r\n          refreshToken,\r\n          retryCount + 1\r\n        );\r\n      })();\r\n    }\r\n    throw err;\r\n  });\r\n}\r\n\r\n/**\r\n * 流式对话补全\r\n *\r\n * @param model 模型名称\r\n * @param messages 参考gpt系列消息格式,多轮对话请完整提供上下文\r\n * @param refreshToken 用于刷新access_token的refresh_token\r\n * @param retryCount 重试次数\r\n */\r\nasync function createCompletionStream(\r\n  model = MODEL_NAME,\r\n  messages: any[],\r\n  refreshToken: string,\r\n  retryCount = 0\r\n) {\r\n  return (async () => {\r\n    logger.info(messages);\r\n\r\n    const result = await chatLock.acquire(refreshToken, async () => {\r\n      // 清除上下文\r\n      await clearContext(model, refreshToken);\r\n      // 请求流\r\n      const token = await acquireToken(refreshToken);\r\n      return await axios.post(\r\n        \"https://chat.deepseek.com/api/v0/chat/completions\",\r\n        {\r\n          message: messagesPrepare(messages),\r\n          stream: true,\r\n          model_preference: null,\r\n          model_class: model,\r\n          temperature: 0\r\n        },\r\n        {\r\n          headers: {\r\n            Authorization: `Bearer ${token}`,\r\n            ...FAKE_HEADERS\r\n          },\r\n          // 120秒超时\r\n          timeout: 120000,\r\n          validateStatus: () => true,\r\n          responseType: \"stream\",\r\n        }\r\n      );\r\n    });\r\n\r\n    if (result.headers[\"content-type\"].indexOf(\"text/event-stream\") == -1) {\r\n      logger.error(\r\n        `Invalid response Content-Type:`,\r\n        result.headers[\"content-type\"]\r\n      );\r\n      result.data.on(\"data\", buffer => logger.error(buffer.toString()));\r\n      const transStream = new PassThrough();\r\n      transStream.end(\r\n        `data: ${JSON.stringify({\r\n          id: \"\",\r\n          model: MODEL_NAME,\r\n          object: \"chat.completion.chunk\",\r\n          choices: [\r\n            {\r\n              index: 0,\r\n              delta: {\r\n                role: \"assistant\",\r\n                content: \"服务暂时不可用,第三方响应错误\",\r\n              },\r\n              finish_reason: \"stop\",\r\n            },\r\n          ],\r\n          usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 },\r\n          created: util.unixTimestamp(),\r\n        })}\\n\\n`\r\n      );\r\n      return transStream;\r\n    }\r\n    const streamStartTime = util.timestamp();\r\n    // 创建转换流将消息格式转换为gpt兼容格式\r\n    return createTransStream(model, result.data, () => {\r\n      logger.success(\r\n        `Stream has completed transfer ${util.timestamp() - streamStartTime}ms`\r\n      );\r\n    });\r\n  })().catch((err) => {\r\n    if (retryCount < MAX_RETRY_COUNT) {\r\n      logger.error(`Stream response error: ${err.stack}`);\r\n      logger.warn(`Try again after ${RETRY_DELAY / 1000}s...`);\r\n      return (async () => {\r\n        await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));\r\n        return createCompletionStream(\r\n          model,\r\n          messages,\r\n          refreshToken,\r\n          retryCount + 1\r\n        );\r\n      })();\r\n    }\r\n    throw err;\r\n  });\r\n}\r\n\r\n/**\r\n * 消息预处理\r\n *\r\n * 由于接口只取第一条消息,此处会将多条消息合并为一条,实现多轮对话效果\r\n *\r\n * @param messages 参考gpt系列消息格式,多轮对话请完整提供上下文\r\n */\r\nfunction messagesPrepare(messages: any[]) {\r\n  let content;\r\n  if (messages.length < 2) {\r\n    content = messages.reduce((content, message) => {\r\n      if (_.isArray(message.content)) {\r\n        return (\r\n          message.content.reduce((_content, v) => {\r\n            if (!_.isObject(v) || v[\"type\"] != \"text\") return _content;\r\n            return _content + (v[\"text\"] || \"\") + \"\\n\";\r\n          }, content)\r\n        );\r\n      }\r\n      return content + `${message.content}\\n`;\r\n    }, \"\");\r\n    logger.info(\"\\n透传内容:\\n\" + content);\r\n  }\r\n  else {\r\n    content = (\r\n      messages.reduce((content, message) => {\r\n        if (_.isArray(message.content)) {\r\n          return (\r\n            message.content.reduce((_content, v) => {\r\n              if (!_.isObject(v) || v[\"type\"] != \"text\") return _content;\r\n              return _content + (`${message.role}:` + v[\"text\"] || \"\") + \"\\n\";\r\n            }, content)\r\n          );\r\n        }\r\n        return (content += `${message.role}:${message.content}\\n`);\r\n      }, \"\") + \"assistant:\"\r\n    )\r\n      // 移除MD图像URL避免幻觉\r\n      .replace(/\\!\\[.+\\]\\(.+\\)/g, \"\");\r\n    logger.info(\"\\n对话合并:\\n\" + content);\r\n  }\r\n  return content;\r\n}\r\n\r\n/**\r\n * 检查请求结果\r\n *\r\n * @param result 结果\r\n * @param refreshToken 用于刷新access_token的refresh_token\r\n */\r\nfunction checkResult(result: AxiosResponse, refreshToken: string) {\r\n  if (!result.data) return null;\r\n  const { code, data, msg } = result.data;\r\n  if (!_.isFinite(code)) return result.data;\r\n  if (code === 0) return data;\r\n  if (code == 40003) accessTokenMap.delete(refreshToken);\r\n  throw new APIException(EX.API_REQUEST_FAILED, `[请求deepseek失败]: ${msg}`);\r\n}\r\n\r\n/**\r\n * 从流接收完整的消息内容\r\n *\r\n * @param model 模型名称\r\n * @param stream 消息流\r\n */\r\nasync function receiveStream(model: string, stream: any): Promise<any> {\r\n  return new Promise((resolve, reject) => {\r\n    // 消息初始化\r\n    const data = {\r\n      id: \"\",\r\n      model,\r\n      object: \"chat.completion\",\r\n      choices: [\r\n        {\r\n          index: 0,\r\n          message: { role: \"assistant\", content: \"\" },\r\n          finish_reason: \"stop\",\r\n        },\r\n      ],\r\n      usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 },\r\n      created: util.unixTimestamp(),\r\n    };\r\n    const parser = createParser((event) => {\r\n      try {\r\n        if (event.type !== \"event\") return;\r\n        // 解析JSON\r\n        const result = _.attempt(() => JSON.parse(event.data));\r\n        if (_.isError(result))\r\n          throw new Error(`Stream response invalid: ${event.data}`);\r\n        if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content == ' ')\r\n          return;\r\n        data.choices[0].message.content += result.choices[0].delta.content;\r\n        if (result.choices && result.choices[0] && result.choices[0].finish_reason === \"stop\")\r\n          resolve(data);\r\n      } catch (err) {\r\n        logger.error(err);\r\n        reject(err);\r\n      }\r\n    });\r\n    // 将流数据喂给SSE转换器\r\n    stream.on(\"data\", (buffer) => parser.feed(buffer.toString()));\r\n    stream.once(\"error\", (err) => reject(err));\r\n    stream.once(\"close\", () => resolve(data));\r\n  });\r\n}\r\n\r\n/**\r\n * 创建转换流\r\n *\r\n * 将流格式转换为gpt兼容流格式\r\n *\r\n * @param model 模型名称\r\n * @param stream 消息流\r\n * @param endCallback 传输结束回调\r\n */\r\nfunction createTransStream(model: string, stream: any, endCallback?: Function) {\r\n  // 消息创建时间\r\n  const created = util.unixTimestamp();\r\n  // 创建转换流\r\n  const transStream = new PassThrough();\r\n  !transStream.closed &&\r\n    transStream.write(\r\n      `data: ${JSON.stringify({\r\n        id: \"\",\r\n        model,\r\n        object: \"chat.completion.chunk\",\r\n        choices: [\r\n          {\r\n            index: 0,\r\n            delta: { role: \"assistant\", content: \"\" },\r\n            finish_reason: null,\r\n          },\r\n        ],\r\n        created,\r\n      })}\\n\\n`\r\n    );\r\n  const parser = createParser((event) => {\r\n    try {\r\n      if (event.type !== \"event\") return;\r\n      // 解析JSON\r\n      const result = _.attempt(() => JSON.parse(event.data));\r\n      if (_.isError(result))\r\n        throw new Error(`Stream response invalid: ${event.data}`);\r\n      if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content == ' ')\r\n        return;\r\n      result.model = model;\r\n      transStream.write(`data: ${JSON.stringify({\r\n        id: result.id,\r\n        model: result.model,\r\n        object: \"chat.completion.chunk\",\r\n        choices: [\r\n          {\r\n            index: 0,\r\n            delta: { role: \"assistant\", content: result.choices[0].delta.content },\r\n            finish_reason: null,\r\n          },\r\n        ],\r\n        created,\r\n      })}\\n\\n`);\r\n      if (result.choices && result.choices[0] && result.choices[0].finish_reason === \"stop\") {\r\n        transStream.write(`data: ${JSON.stringify({\r\n          id: result.id,\r\n          model: result.model,\r\n          object: \"chat.completion.chunk\",\r\n          choices: [\r\n            {\r\n              index: 0,\r\n              delta: { role: \"assistant\", content: \"\" },\r\n              finish_reason: \"stop\"\r\n            },\r\n          ],\r\n          created,\r\n        })}\\n\\n`);\r\n        !transStream.closed && transStream.end(\"data: [DONE]\\n\\n\");\r\n      }\r\n    } catch (err) {\r\n      logger.error(err);\r\n      !transStream.closed && transStream.end(\"data: [DONE]\\n\\n\");\r\n    }\r\n  });\r\n  // 将流数据喂给SSE转换器\r\n  stream.on(\"data\", (buffer) => parser.feed(buffer.toString()));\r\n  stream.once(\r\n    \"error\",\r\n    () => !transStream.closed && transStream.end(\"data: [DONE]\\n\\n\")\r\n  );\r\n  stream.once(\r\n    \"close\",\r\n    () => !transStream.closed && transStream.end(\"data: [DONE]\\n\\n\")\r\n  );\r\n  return transStream;\r\n}\r\n\r\n/**\r\n * Token切分\r\n *\r\n * @param authorization 认证字符串\r\n */\r\nfunction tokenSplit(authorization: string) {\r\n  return authorization.replace(\"Bearer \", \"\").split(\",\");\r\n}\r\n\r\n/**\r\n * 获取Token存活状态\r\n */\r\nasync function getTokenLiveStatus(refreshToken: string) {\r\n  const token = await acquireToken(refreshToken);\r\n  const result = await axios.get(\r\n    \"https://chat.deepseek.com/api/v0/users/current\",\r\n    {\r\n      headers: {\r\n        Authorization: `Bearer ${token}`,\r\n        ...FAKE_HEADERS,\r\n      },\r\n      timeout: 15000,\r\n      validateStatus: () => true,\r\n    }\r\n  );\r\n  try {\r\n    const { token } = checkResult(result, refreshToken);\r\n    return !!token;\r\n  }\r\n  catch (err) {\r\n    return false;\r\n  }\r\n}\r\n\r\nexport default {\r\n  createCompletion,\r\n  createCompletionStream,\r\n  getTokenLiveStatus,\r\n  tokenSplit,\r\n};\r\n","export default {\r\n  prefix: '/ping',\r\n  get: {\r\n    '': async () => \"pong\"\r\n  }\r\n}","import _ from 'lodash';\r\n\r\nimport Request from '@/lib/request/Request.ts';\r\nimport Response from '@/lib/response/Response.ts';\r\nimport chat from '@/api/controllers/chat.ts';\r\nimport logger from '@/lib/logger.ts';\r\n\r\nexport default {\r\n\r\n    prefix: '/token',\r\n\r\n    post: {\r\n\r\n        '/check': async (request: Request) => {\r\n            request\r\n                .validate('body.token', _.isString)\r\n            const live = await chat.getTokenLiveStatus(request.body.token);\r\n            return {\r\n                live\r\n            }\r\n        }\r\n\r\n    }\r\n\r\n}","import _ from 'lodash';\r\n\r\nexport default {\r\n\r\n    prefix: '/v1',\r\n\r\n    get: {\r\n        '/models': async () => {\r\n            return {\r\n                \"data\": [\r\n                    {\r\n                        \"id\": \"deepseek-chat\",\r\n                        \"object\": \"model\",\r\n                        \"owned_by\": \"deepseek-free-api\"\r\n                    },\r\n                    {\r\n                        \"id\": \"deepseek-coder\",\r\n                        \"object\": \"model\",\r\n                        \"owned_by\": \"deepseek-free-api\"\r\n                    }\r\n                ]\r\n            };\r\n        }\r\n\r\n    }\r\n}","\"use strict\";\r\n\r\nimport environment from \"@/lib/environment.ts\";\r\nimport config from \"@/lib/config.ts\";\r\nimport \"@/lib/initialize.ts\";\r\nimport server from \"@/lib/server.ts\";\r\nimport routes from \"@/api/routes/index.ts\";\r\nimport logger from \"@/lib/logger.ts\";\r\n\r\nconst startupTime = performance.now();\r\n\r\n(async () => {\r\n  logger.header();\r\n\r\n  logger.info(\"<<<< deepseek free server >>>>\");\r\n  logger.info(\"Version:\", environment.package.version);\r\n  logger.info(\"Process id:\", process.pid);\r\n  logger.info(\"Environment:\", environment.env);\r\n  logger.info(\"Service name:\", config.service.name);\r\n\r\n  server.attachRoutes(routes);\r\n  await server.listen();\r\n\r\n  config.service.bindAddress &&\r\n    logger.success(\"Service bind address:\", config.service.bindAddress);\r\n})()\r\n  .then(() =>\r\n    logger.success(\r\n      `Service startup completed (${Math.floor(performance.now() - startupTime)}ms)`\r\n    )\r\n  )\r\n  .catch((err) => console.error(err));\r\n"],"mappings":";AAAA,OAAO,UAAU;AAEjB,OAAO,QAAQ;AACf,OAAO,cAAc;AACrB,OAAO,OAAO;AAEd,IAAM,UAAU,SAAS,QAAQ,KAAK,MAAM,CAAC,CAAC;AAC9C,IAAM,UAAU,QAAQ;AAExB,IAAM,cAAN,MAAkB;AAAA;AAAA,EAGd;AAAA;AAA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M,UAAU,MAAMC,IAAG,SAAS,qBAAqB;AACvD,eAAO,IAAI,SAAS,SAAS;AAAA,UACzB,MAAM;AAAA,UACN,SAAS;AAAA,YACL,SAAS;AAAA,UACb;AAAA,QACJ,CAAC;AAAA,MACL;AAAA,IACJ;AAAA,EACJ;AAAA,EACAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;;;AMjBA,IAAM,cAAc,YAAY,IAAI;AAAA,CAEnC,YAAY;AACX,iBAAO,OAAO;AAEd,iBAAO,KAAK,gCAAgC;AAC5C,iBAAO,KAAK,YAAY,oBAAY,QAAQ,OAAO;AACnD,iBAAO,KAAK,eAAe,QAAQ,GAAG;AACtC,iBAAO,KAAK,gBAAgB,oBAAY,GAAG;AAC3C,iBAAO,KAAK,iBAAiB,eAAO,QAAQ,IAAI;AAEhD,iBAAO,aAAa,cAAM;AAC1B,QAAM,eAAO,OAAO;AAEpB,iBAAO,QAAQ,eACb,eAAO,QAAQ,yBAAyB,eAAO,QAAQ,WAAW;AACtE,GAAG,EACA;AAAA,EAAK,MACJ,eAAO;AAAA,IACL,8BAA8B,KAAK,MAAM,YAAY,IAAI,IAAI,WAAW,CAAC;AAAA,EAC3E;AACF,EACC,MAAM,CAAC,QAAQ,QAAQ,MAAM,GAAG,CAAC;","names":["cmdArgs","envVars","path","fs","_","path","fs","_","_","path","fs","path","_","fs","path","fs","yaml","_","CONFIG_PATH","path","_","fs","yaml","path","_","fs","dateFormat","fs","path","_","dateFormat","_","_","_","_","_","mime","_","_","_","mime","_","exceptions_default","_","exceptions_default","_","response","err","fs","_","_","axios","result","axios","_","content","token","chat_default","_","stream","_","_","fs","chat_default"]}