-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
235 lines (201 loc) · 5.37 KB
/
index.ts
File metadata and controls
235 lines (201 loc) · 5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/* eslint-disable @typescript-eslint/naming-convention */
/**
* Project: Kebab, User: JianSuoQiYue
* Date: 2019-3-30 12:46:41
* Last: 2020-3-8 21:04:24, 2022-07-22 14:20:34, 2023-5-24 01:34:57, 2025-6-13 14:49:27, 2025-10-1 10:11:54
* --- 本文件用来定义每个目录实体地址的常量 ---
*/
/** --- 当前系统版本号 --- */
export const VER = '9.3.12';
// --- 服务端用的路径 ---
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
/** --- /xxx/xxx --- */
const dirname = imu.slice(0, imu.lastIndexOf('/'));
/** --- 框架根目录,以 / 结尾 --- */
export const ROOT_PATH = dirname + '/';
/** --- 框架的 LIB,以 / 结尾 --- */
export const LIB_PATH = ROOT_PATH + 'lib/';
export const SYS_PATH = ROOT_PATH + 'sys/';
let cwd = process.cwd().replace(/\\/g, '/');
if (cwd.endsWith('source')) {
// --- 开发环境下,cwd 在 source 的上级目录 ---
cwd = cwd.slice(0, -7);
}
/** --- 执行根目录,以 / 结尾 --- */
export const ROOT_CWD = cwd + '/';
export const CONF_CWD = ROOT_CWD + 'conf/';
export const CERT_CWD = CONF_CWD + 'cert/';
export const VHOST_CWD = CONF_CWD + 'vhost/';
/** --- 用户的根 LIB,以 / 结尾 --- */
export const LIB_CWD = ROOT_CWD + 'lib/';
export const LOG_CWD = ROOT_CWD + 'log/';
export const WWW_CWD = ROOT_CWD + 'www/';
export const IND_CWD = ROOT_CWD + 'ind/';
export const FTMP_CWD = ROOT_CWD + 'ftmp/';
export const MOD_CWD = ROOT_CWD + 'mod/';
// --- 类型 ---
/** --- 除非确定是不可知的 Json,否则不能使用 --- */
export type Json = any;
/** --- 数据库值的类型 --- */
export type DbValue = string | number | null | Record<string, Json>;
/** --- 目录配置文件 --- */
export interface IConfig {
'set': {
'timezone': number;
'mustHttps': boolean;
'cacheTtl': number;
'staticVer': string;
'staticPath': string;
'staticPathFull': string;
[key: string]: Json;
};
'const': IConfigConst;
'db': Record<string, {
'default': IConfigDb;
'read': IConfigDb;
}> & {
'default': 'MYSQL' | 'PGSQL';
};
'kv': IConfigKv;
'route': Record<string, string>;
'session': {
'name': string;
'ttl': number;
'ssl': boolean;
};
'sql': IConfigSql;
'dns': Record<string, IConfigDns>;
'lang': IConfigLang;
's3': Record<string, IConfigS3>;
'turnstile': IConfigTurnstile;
'ai': Record<string, IConfigAi>;
'vector': IConfigVector;
[key: string]: Record<string, Json>;
}
export interface IUrlParse {
'protocol': string | null;
'auth': string | null;
'user': string | null;
'pass': string | null;
'host': string | null;
'hostname': string | null;
'port': string | null;
'pathname': string;
'path': string | null;
'query': string | null;
'hash': string | null;
}
/** --- 语言 --- */
export interface IConfigLang {
'list': string[];
'direct': string[];
}
/** --- 对象存储 --- */
export interface IConfigS3 {
/** --- cf r2 要用 --- */
'account'?: string;
'sid': string;
'skey': string;
'region': string;
'bucket': string;
}
/** --- AI --- */
export interface IConfigAi {
/** --- 目前只有微软 Azure 有 --- */
'endpoint'?: string;
'skey': string;
}
/** --- 向量数据库 --- */
export interface IConfigVector {
'host': string;
'port': number;
'name': string;
'user': string;
'pwd': string;
}
/** --- 人机码信息 --- */
export interface IConfigTurnstile {
'CF': {
'sid': string;
'skey': string;
};
'TENCENT': {
'sid': string;
'skey': string;
'aid': string;
'akey': string;
};
}
/** --- 数据库 --- */
export interface IConfigDb {
'host': string;
'port': number;
'charset'?: string;
'name'?: string;
'user': string;
'pwd': string;
}
/** --- DNS --- */
export interface IConfigDns {
'sid': string;
'skey': string;
}
/** --- kv --- */
export interface IConfigKv {
'host': string;
'port': number;
'index': number;
'pre': string;
'user': string;
'pwd': string;
}
/** --- sql --- */
export interface IConfigSql {
'pre': string;
}
/** --- 常量 --- */
export interface IConfigConst {
/** --- 不以 / 开头,不含 qs --- */
'path': string;
/** --- 不含 ? 开头 --- */
'qs': string;
/** --- 含 ? 开头 --- */
'qss': string;
'startTime': bigint;
'startMemory': number;
// --- 环境判断 ---
'mobile': boolean;
'wechat': boolean;
'miniprogram': '' | 'wechat';
'https': boolean;
'host': string;
'hostname': string;
'hostport': number;
'uri': IUrlParse;
// --- 服务端用的路径 ---
'rootPath': string;
'modPath': string;
'ctrPath': string;
'viewPath': string;
'dataPath': string;
'wsPath': string;
// --- 前端用的路径 ---
'urlBase': string;
'urlStc': string;
'urlFull': string;
'urlStcFull': string;
}
/** --- 虚拟机配置对象 --- */
export interface IVhost {
readonly 'name'?: string;
readonly 'domains': string[];
readonly 'root': string;
readonly 'remark'?: string;
}
/** --- 上传的文件信息对象 --- */
export interface IPostFile {
readonly 'name': string;
readonly 'origin': string;
readonly 'size': number;
readonly 'path': string;
}