@x-9lab/xlab 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,42 @@
1
+ /// <reference types="node" />
1
2
  import type Koa from "koa";
3
+ import url from "url";
4
+ /**资源类型 */
5
+ interface ISrcType {
6
+ /**是否是 js 文件 */
7
+ js: boolean;
8
+ /**是否是 html 文件 */
9
+ html: boolean;
10
+ /**是否是图片文件 */
11
+ img: boolean;
12
+ /**是否是 css 文件 */
13
+ css: boolean;
14
+ /**是否是文件夹 */
15
+ dir: boolean;
16
+ /**是否是静态文件 */
17
+ static: boolean;
18
+ /**是否是模板文件 */
19
+ tpl: boolean;
20
+ /**是否是字体文件 */
21
+ font: boolean;
22
+ }
23
+ declare module "koa" {
24
+ /**系统默认 state */
25
+ interface DefaultState {
26
+ /**资源类型 */
27
+ srcType: ISrcType;
28
+ /**请求域名 */
29
+ originHost: string | string[];
30
+ /**请求版本 */
31
+ ver: Record<string, string>;
32
+ /**
33
+ 经过解析后的请求 url
34
+
35
+ @see `https://nodejs.org/dist/latest-v16.x/docs/api/url.html`
36
+ */
37
+ parsedUrl: url.Url;
38
+ }
39
+ }
2
40
  declare function filter(ctx: Koa.Context, next: Koa.Next): Promise<void>;
3
41
  export default function (): typeof filter;
4
42
  export {};
package/dist/dot-file.js CHANGED
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "processDotFile", {
6
6
  enumerable: true,
7
7
  get: ()=>processDotFile
8
8
  });
9
+ const _utils = require("@x-drive/utils");
9
10
  const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
10
11
  const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
- const _utils = require("@x-drive/utils");
12
12
  function _interopRequireDefault(obj) {
13
13
  return obj && obj.__esModule ? obj : {
14
14
  default: obj
@@ -15,7 +15,7 @@ const _utils = require("@x-drive/utils");
15
15
  "localhost": true,
16
16
  "127.0.0.1": true
17
17
  };
18
- /**根域获取正则 */ const ROOT_NAME_REGEXP = /[\w-]*\.(?:com|cc|cn|asia|biz|coop|edu|gov|int|info|jobs|mobi|name|net|org|pro|tel|trave)(\.[a-z]{2})?/im;
18
+ /**根域获取正则 */ const ROOT_NAME_REGEXP = /[\w-]*\.(?:com|lo|cc|cn|asia|biz|coop|edu|gov|int|info|jobs|mobi|name|net|org|pro|tel|trave)(\.[a-z]{2})?/im;
19
19
  /**获取域名根域 */ function getRootName(host) {
20
20
  const match = host.match(ROOT_NAME_REGEXP);
21
21
  if (match && (0, _utils.isString)(match[0])) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@x-9lab/xlab",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "9lab 服务端模块",
5
- "versionDesc": "支持根目录下的点配置文件",
5
+ "versionDesc": "cors 支持 .lo 本地域名",
6
6
  "scripts": {
7
7
  "dev": "swc src -D ./src/bin --config-file .swcrc -d dist -w",
8
8
  "compile": "swc src -D ./src/bin --config-file .swcrc -d dist",