@modern-js/bff-core 1.0.1-beta.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +224 -0
  2. package/LICENSE +21 -0
  3. package/README.md +30 -0
  4. package/dist/js/modern/api.js +59 -0
  5. package/dist/js/modern/client/generate-client.js +64 -0
  6. package/dist/js/modern/client/index.js +1 -0
  7. package/dist/js/modern/client/result.js +20 -0
  8. package/dist/js/modern/errors/http.js +13 -0
  9. package/dist/js/modern/index.js +7 -0
  10. package/dist/js/modern/operators/http.js +183 -0
  11. package/dist/js/modern/router/constants.js +13 -0
  12. package/dist/js/modern/router/index.js +271 -0
  13. package/dist/js/modern/router/types.js +1 -0
  14. package/dist/js/modern/router/utils.js +53 -0
  15. package/dist/js/modern/types.js +42 -0
  16. package/dist/js/modern/utils.js +61 -0
  17. package/dist/js/node/api.js +71 -0
  18. package/dist/js/node/client/generate-client.js +82 -0
  19. package/dist/js/node/client/index.js +18 -0
  20. package/dist/js/node/client/result.js +32 -0
  21. package/dist/js/node/errors/http.js +25 -0
  22. package/dist/js/node/index.js +102 -0
  23. package/dist/js/node/operators/http.js +227 -0
  24. package/dist/js/node/router/constants.js +27 -0
  25. package/dist/js/node/router/index.js +317 -0
  26. package/dist/js/node/router/types.js +5 -0
  27. package/dist/js/node/router/utils.js +74 -0
  28. package/dist/js/node/types.js +53 -0
  29. package/dist/js/node/utils.js +85 -0
  30. package/dist/types/api.d.ts +3 -0
  31. package/dist/types/client/generate-client.d.ts +24 -0
  32. package/dist/types/client/index.d.ts +1 -0
  33. package/dist/types/client/result.d.ts +15 -0
  34. package/dist/types/errors/http.d.ts +5 -0
  35. package/dist/types/index.d.ts +7 -0
  36. package/dist/types/operators/http.d.ts +28 -0
  37. package/dist/types/router/constants.d.ts +16 -0
  38. package/dist/types/router/index.d.ts +46 -0
  39. package/dist/types/router/types.d.ts +17 -0
  40. package/dist/types/router/utils.d.ts +7 -0
  41. package/dist/types/types.d.ts +54 -0
  42. package/dist/types/utils.d.ts +7 -0
  43. package/package.json +89 -0
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.requireHandlerModule = exports.isHandler = exports.getPathFromFilename = exports.getFiles = void 0;
7
+
8
+ var _path = _interopRequireDefault(require("path"));
9
+
10
+ var _utils = require("@modern-js/utils");
11
+
12
+ var _constants = require("./constants");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const getFiles = (lambdaDir, rules) => _utils.globby.sync(rules, {
17
+ cwd: lambdaDir,
18
+ gitignore: true
19
+ }).map(file => _path.default.resolve(lambdaDir, file));
20
+
21
+ exports.getFiles = getFiles;
22
+
23
+ const getPathFromFilename = (baseDir, filename) => {
24
+ const relativeName = filename.substring(baseDir.length);
25
+ const relativePath = relativeName.split('.').slice(0, -1).join('.');
26
+ const nameSplit = relativePath.split(_path.default.sep).map(item => {
27
+ if (item.length > 2) {
28
+ if (item.startsWith('[') && item.endsWith(']')) {
29
+ return `:${item.substring(1, item.length - 1)}`;
30
+ }
31
+ }
32
+
33
+ return item;
34
+ });
35
+ const name = nameSplit.join('/');
36
+ const finalName = name.endsWith(_constants.INDEX_SUFFIX) ? name.substring(0, name.length - _constants.INDEX_SUFFIX.length) : name;
37
+ return clearRouteName(finalName);
38
+ };
39
+
40
+ exports.getPathFromFilename = getPathFromFilename;
41
+
42
+ const clearRouteName = routeName => {
43
+ let finalRouteName = routeName.trim();
44
+
45
+ if (!finalRouteName.startsWith('/')) {
46
+ finalRouteName = `/${finalRouteName}`;
47
+ }
48
+
49
+ if (finalRouteName.length > 1 && finalRouteName.endsWith('/')) {
50
+ finalRouteName = finalRouteName.substring(0, finalRouteName.length - 1);
51
+ }
52
+
53
+ return finalRouteName;
54
+ };
55
+
56
+ const isHandler = input => input && typeof input === 'function';
57
+
58
+ exports.isHandler = isHandler;
59
+
60
+ const isFunction = input => input && {}.toString.call(input) === '[object Function]';
61
+
62
+ const requireHandlerModule = modulePath => {
63
+ const module = require(modulePath);
64
+
65
+ if (isFunction(module)) {
66
+ return {
67
+ default: module
68
+ };
69
+ }
70
+
71
+ return module;
72
+ };
73
+
74
+ exports.requireHandlerModule = requireHandlerModule;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.httpMethods = exports.TriggerType = exports.OperatorType = exports.HttpMethod = exports.HttpMetadata = void 0;
7
+ let OperatorType;
8
+ exports.OperatorType = OperatorType;
9
+
10
+ (function (OperatorType) {
11
+ OperatorType[OperatorType["Trigger"] = 0] = "Trigger";
12
+ OperatorType[OperatorType["Middleware"] = 1] = "Middleware";
13
+ })(OperatorType || (exports.OperatorType = OperatorType = {}));
14
+
15
+ let TriggerType;
16
+ exports.TriggerType = TriggerType;
17
+
18
+ (function (TriggerType) {
19
+ TriggerType[TriggerType["Http"] = 0] = "Http";
20
+ })(TriggerType || (exports.TriggerType = TriggerType = {}));
21
+
22
+ let HttpMetadata;
23
+ exports.HttpMetadata = HttpMetadata;
24
+
25
+ (function (HttpMetadata) {
26
+ HttpMetadata["Method"] = "METHOD";
27
+ HttpMetadata["Data"] = "DATA";
28
+ HttpMetadata["Query"] = "QUERY";
29
+ HttpMetadata["Params"] = "PARAMS";
30
+ HttpMetadata["Headers"] = "HEADERS";
31
+ HttpMetadata["Response"] = "RESPONSE";
32
+ HttpMetadata["StatusCode"] = "STATUS_CODE";
33
+ HttpMetadata["Redirect"] = "REDIRECT";
34
+ HttpMetadata["ResponseHeaders"] = "RESPONSE_HEADERS";
35
+ })(HttpMetadata || (exports.HttpMetadata = HttpMetadata = {}));
36
+
37
+ let HttpMethod;
38
+ exports.HttpMethod = HttpMethod;
39
+
40
+ (function (HttpMethod) {
41
+ HttpMethod["Get"] = "GET";
42
+ HttpMethod["Post"] = "POST";
43
+ HttpMethod["Put"] = "PUT";
44
+ HttpMethod["Delete"] = "DELETE";
45
+ HttpMethod["Connect"] = "CONNECT";
46
+ HttpMethod["Trace"] = "TRACE";
47
+ HttpMethod["Patch"] = "PATCH";
48
+ HttpMethod["Option"] = "OPTION";
49
+ HttpMethod["Head"] = "HEAD";
50
+ })(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
51
+
52
+ const httpMethods = Object.values(HttpMethod);
53
+ exports.httpMethods = httpMethods;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateFunction = exports.isWithMetaHandler = exports.getTypeErrorMessage = exports.HANDLER_WITH_META = exports.ERR_INVALID_ARG_TYPE = void 0;
7
+
8
+ var _util = _interopRequireDefault(require("util"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const HANDLER_WITH_META = 'HANDLER_WITH_SCHEMA'; // export const pick = <T extends Record<string, unknown>, K extends keyof T>(
13
+ // obj: T,
14
+ // keys: readonly K[],
15
+ // ) => {
16
+ // Object.entries(obj).filter(([key]) => {
17
+ // return (keys as readonly string[]).includes(key);
18
+ // });
19
+ // };
20
+ // fork from https://github.com/nodejs/node/blob/master/lib/internal/errors.js
21
+
22
+ exports.HANDLER_WITH_META = HANDLER_WITH_META;
23
+
24
+ const getTypeErrorMessage = actual => {
25
+ let msg = '';
26
+
27
+ if (actual == null) {
28
+ msg += `. Received ${actual}`;
29
+ } else if (typeof actual === 'function' && actual.name) {
30
+ msg += `. Received function ${actual.name}`;
31
+ } else if (typeof actual === 'object') {
32
+ var _actual$constructor;
33
+
34
+ if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
35
+ msg += `. Received an instance of ${actual.constructor.name}`;
36
+ } else {
37
+ const inspected = _util.default.inspect(actual, {
38
+ depth: -1
39
+ });
40
+
41
+ msg += `. Received ${inspected}`;
42
+ }
43
+ } else {
44
+ let inspected = _util.default.inspect(actual, {
45
+ colors: false
46
+ });
47
+
48
+ if (inspected.length > 25) {
49
+ inspected = `${inspected.slice(0, 25)}...`;
50
+ }
51
+
52
+ msg += `. Received type ${typeof actual} (${inspected})`;
53
+ }
54
+
55
+ return msg;
56
+ }; // eslint-disable-next-line @typescript-eslint/naming-convention
57
+
58
+
59
+ exports.getTypeErrorMessage = getTypeErrorMessage;
60
+
61
+ class ERR_INVALID_ARG_TYPE extends Error {
62
+ constructor(funcName, expectedType, actual) {
63
+ const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(actual)}`;
64
+ super(message);
65
+ }
66
+
67
+ }
68
+
69
+ exports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;
70
+
71
+ const validateFunction = (maybeFunc, name) => {
72
+ if (typeof maybeFunc !== 'function') {
73
+ throw new ERR_INVALID_ARG_TYPE(name, 'function', maybeFunc);
74
+ }
75
+
76
+ return true;
77
+ };
78
+
79
+ exports.validateFunction = validateFunction;
80
+
81
+ const isWithMetaHandler = handler => {
82
+ return typeof handler === 'function' && handler[HANDLER_WITH_META];
83
+ };
84
+
85
+ exports.isWithMetaHandler = isWithMetaHandler;
@@ -0,0 +1,3 @@
1
+ import 'reflect-metadata';
2
+ import type { ApiRunner, ArrayToObject, ExtractInputType, Operator, MaybeAsync } from './types';
3
+ export declare function Api<Operators extends Operator<any>[], Res extends MaybeAsync<any>>(...args: [...operators: Operators, handler: (arg: ArrayToObject<ExtractInputType<Operators>>) => Res]): ApiRunner<ExtractInputType<Operators> extends void[] ? void : ArrayToObject<ExtractInputType<Operators>>, Res>;
@@ -0,0 +1,24 @@
1
+ import { Result } from './result';
2
+ export declare type GenClientResult = Result<string>;
3
+ export declare type GenClientOptions = {
4
+ resourcePath: string;
5
+ source: string;
6
+ apiDir: string;
7
+ prefix: string;
8
+ port: number;
9
+ requestCreator?: string;
10
+ fetcher?: string;
11
+ target?: string;
12
+ requireResolve?: typeof require.resolve;
13
+ };
14
+ export declare const DEFAULT_CLIENT_REQUEST_CREATOR = "@modern-js/create-request";
15
+ export declare const generateClient: ({
16
+ resourcePath,
17
+ apiDir,
18
+ prefix,
19
+ port,
20
+ target,
21
+ requestCreator,
22
+ fetcher,
23
+ requireResolve
24
+ }: GenClientOptions) => Promise<GenClientResult>;
@@ -0,0 +1 @@
1
+ export * from './generate-client';
@@ -0,0 +1,15 @@
1
+ export declare type Err<T = any> = {
2
+ kind: 'Err';
3
+ value: T;
4
+ isErr: true;
5
+ isOk: false;
6
+ };
7
+ export declare type Ok<T = any> = {
8
+ kind: 'Ok';
9
+ value: T;
10
+ isErr: false;
11
+ isOk: true;
12
+ };
13
+ export declare type Result<T = any, E = string> = Err<E> | Ok<T>;
14
+ export declare const Err: <E = string>(value: E) => Err<E>;
15
+ export declare const Ok: <T, E = string>(value: T) => Result<T, E>;
@@ -0,0 +1,5 @@
1
+ export declare class HttpError extends Error {
2
+ status: number;
3
+ constructor(status: number, message: string);
4
+ }
5
+ export declare class ValidationError extends HttpError {}
@@ -0,0 +1,7 @@
1
+ export { Api } from './api';
2
+ export { HttpError, ValidationError } from './errors/http';
3
+ export * from './router';
4
+ export * from './types';
5
+ export * from './utils';
6
+ export * from './client';
7
+ export * from './operators/http';
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { Operator, HttpMethod, ApiMiddleware } from '../types';
3
+ export declare const createHttpOperator: (method: HttpMethod) => (urlPath: string) => Operator<void>;
4
+ export declare const Get: (urlPath: string) => Operator<void>;
5
+ export declare const Post: (urlPath: string) => Operator<void>;
6
+ export declare const Put: (urlPath: string) => Operator<void>;
7
+ export declare const Delete: (urlPath: string) => Operator<void>;
8
+ export declare const Connect: (urlPath: string) => Operator<void>;
9
+ export declare const Trace: (urlPath: string) => Operator<void>;
10
+ export declare const Patch: (urlPath: string) => Operator<void>;
11
+ export declare const Option: (urlPath: string) => Operator<void>;
12
+ export declare const Head: (urlPath: string) => Operator<void>;
13
+ export declare const Data: <T>(schema: z.ZodType<T, z.ZodTypeDef, T>) => Operator<{
14
+ data: T;
15
+ }>;
16
+ export declare const Query: <T>(schema: z.ZodType<T, z.ZodTypeDef, T>) => Operator<{
17
+ query: T;
18
+ }>;
19
+ export declare const Params: <T>(schema: z.ZodType<T, z.ZodTypeDef, T>) => Operator<{
20
+ params: T;
21
+ }>;
22
+ export declare const Headers: <T>(schema: z.ZodType<T, z.ZodTypeDef, T>) => Operator<{
23
+ headers: T;
24
+ }>;
25
+ export declare const HttpCode: (statusCode: number) => Operator<void>;
26
+ export declare const SetHeaders: (headers: Record<string, string>) => Operator<void>;
27
+ export declare const Redirect: (url: string) => Operator<void>;
28
+ export declare const Middleware: (middleware: ApiMiddleware) => Operator<void>;
@@ -0,0 +1,16 @@
1
+ export declare const AllHttpMethods: string[];
2
+ export declare enum APIMode {
3
+ /**
4
+ * 框架模式
5
+ */
6
+ FARMEWORK = "FARMEWORK",
7
+
8
+ /**
9
+ * 函数模式
10
+ */
11
+ FUNCTION = "FUNCTION",
12
+ }
13
+ export declare const FRAMEWORK_MODE_LAMBDA_DIR = "lambda";
14
+ export declare const INDEX_SUFFIX = "index";
15
+ export declare const API_DIR = "api";
16
+ export declare const API_FILE_RULES: string[];
@@ -0,0 +1,46 @@
1
+ import 'reflect-metadata';
2
+ import 'esbuild-register';
3
+ import { HttpMethod } from '../types';
4
+ import { ApiHandler, APIHandlerInfo } from './types';
5
+ export * from './types';
6
+ export * from './constants';
7
+ export declare class ApiRouter {
8
+ private apiDir;
9
+ private lambdaDir;
10
+ private prefix;
11
+ private apiFiles;
12
+ constructor({
13
+ apiDir,
14
+ lambdaDir,
15
+ prefix
16
+ }: {
17
+ apiDir: string;
18
+ lambdaDir?: string;
19
+ prefix?: string;
20
+ });
21
+ /**
22
+ * 如果用户未传入或传入空串,默认为 /api
23
+ * 如果传入 /,则 prefix 为 /
24
+ */
25
+
26
+ private initPrefix;
27
+ private validateAbsolute;
28
+ private getAPIMode;
29
+ private createExistChecker;
30
+ private getLambdaDir;
31
+ private getModuleInfos;
32
+ private getModuleInfo;
33
+ private getHandlerInfos;
34
+ private getModuleHandlerInfos;
35
+ private validateValidApifile;
36
+ private getRoutePath;
37
+ isApiFile(filename: string): boolean;
38
+ getSingleModuleHandlers(filename: string): APIHandlerInfo[] | null;
39
+ getHandlerInfo(filename: string, originFuncName: string, handler: ApiHandler): APIHandlerInfo | null;
40
+ getSafeRoutePath(filename: string, handler?: ApiHandler): string;
41
+ getRouteName(filename: string, handler?: ApiHandler): string;
42
+ getHttpMethod(originHandlerName: string, handler?: ApiHandler): HttpMethod | null;
43
+ loadApiFiles(): string[];
44
+ getApiFiles(): string[];
45
+ getApiHandlers(): APIHandlerInfo[];
46
+ }
@@ -0,0 +1,17 @@
1
+ import { HttpMethod } from '../types';
2
+ export declare type ModuleInfo = {
3
+ filename: string;
4
+ module: HandlerModule;
5
+ };
6
+ declare type Handler = (...args: any) => any | Promise<any>;
7
+ export declare type ApiHandler = Handler;
8
+ export declare type HandlerModule = Record<string, ApiHandler>;
9
+ export declare type APIHandlerInfo = {
10
+ handler: ApiHandler;
11
+ name: string;
12
+ httpMethod: HttpMethod;
13
+ filename: string;
14
+ routeName: string;
15
+ routePath: string;
16
+ };
17
+ export {};
@@ -0,0 +1,7 @@
1
+ import { MaybeAsync } from '@modern-js/bff-runtime';
2
+ export declare type NormalHandler = (...args: any[]) => any;
3
+ export declare type Handler<I, O> = (input: I) => MaybeAsync<O>;
4
+ export declare const getFiles: (lambdaDir: string, rules: string | string[]) => string[];
5
+ export declare const getPathFromFilename: (baseDir: string, filename: string) => string;
6
+ export declare const isHandler: (input: any) => input is Handler<any, any>;
7
+ export declare const requireHandlerModule: (modulePath: string) => any;
@@ -0,0 +1,54 @@
1
+ import { Merge } from 'type-fest';
2
+ export declare enum OperatorType {
3
+ Trigger = 0,
4
+ Middleware = 1,
5
+ }
6
+ export declare enum TriggerType {
7
+ Http = 0,
8
+ }
9
+ export declare enum HttpMetadata {
10
+ Method = "METHOD",
11
+ Data = "DATA",
12
+ Query = "QUERY",
13
+ Params = "PARAMS",
14
+ Headers = "HEADERS",
15
+ Response = "RESPONSE",
16
+ StatusCode = "STATUS_CODE",
17
+ Redirect = "REDIRECT",
18
+ ResponseHeaders = "RESPONSE_HEADERS",
19
+ }
20
+ export declare enum HttpMethod {
21
+ Get = "GET",
22
+ Post = "POST",
23
+ Put = "PUT",
24
+ Delete = "DELETE",
25
+ Connect = "CONNECT",
26
+ Trace = "TRACE",
27
+ Patch = "PATCH",
28
+ Option = "OPTION",
29
+ Head = "HEAD",
30
+ }
31
+ export declare type InputSchemaMeata = Extract<HttpMetadata, HttpMetadata.Data | HttpMetadata.Query | HttpMetadata.Headers | HttpMetadata.Params>;
32
+ export declare type ValidateFunc = (helper: ExecuteHelper, next: () => Promise<any>) => Promise<any>;
33
+ export declare type ExecuteHelper = {
34
+ result?: any;
35
+ readonly inputs: any;
36
+ };
37
+ export declare type MetadataHelper = {
38
+ setMetadata: <T = any>(key: any, value: T) => void;
39
+ getMetadata: <T = any>(key: any) => T;
40
+ };
41
+ export declare type Operator<Input> = {
42
+ name: string;
43
+ inputType?: Input;
44
+ metadata?: (helper: MetadataHelper) => void;
45
+ validate?: ValidateFunc;
46
+ };
47
+ export declare type MaybeAsync<T> = Promise<T> | T;
48
+ export declare type ApiRunner<Input extends object | void | unknown, Output extends MaybeAsync<any>> = (...args: Input extends void ? never : [input: Input]) => Output;
49
+ export declare type NonNullable<T> = Exclude<T, null | undefined>;
50
+ export declare type ExtractInputType<T> = { [key in keyof T]: T[key] extends Operator<any> ? NonNullable<T[key]['inputType']> : void };
51
+ export declare type ArrayToObject<T, R = {}> = T extends [infer First, ...infer Rest] ? First extends PromiseLike<infer PromiseValue> ? PromiseValue : First extends object ? Merge<First, ArrayToObject<Rest, R>> : ArrayToObject<Rest, R> : R;
52
+ export declare type AsyncFunction = (...args: any[]) => Promise<any>;
53
+ export declare const httpMethods: HttpMethod[];
54
+ export declare type ApiMiddleware = (next: () => any | Promise<any>) => any;
@@ -0,0 +1,7 @@
1
+ export declare const HANDLER_WITH_META = "HANDLER_WITH_SCHEMA";
2
+ export declare const getTypeErrorMessage: (actual: unknown) => string;
3
+ export declare class ERR_INVALID_ARG_TYPE extends Error {
4
+ constructor(funcName: string, expectedType: string, actual: unknown);
5
+ }
6
+ export declare const validateFunction: (maybeFunc: unknown, name: string) => boolean;
7
+ export declare const isWithMetaHandler: (handler: any) => any;
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "@modern-js/bff-core",
3
+ "description": "The meta-framework suite designed from scratch for frontend-focused modern web development.",
4
+ "homepage": "https://modernjs.dev",
5
+ "bugs": "https://github.com/modern-js-dev/modern.js/issues",
6
+ "repository": "modern-js-dev/modern.js",
7
+ "license": "MIT",
8
+ "keywords": [
9
+ "react",
10
+ "framework",
11
+ "modern",
12
+ "modern.js"
13
+ ],
14
+ "version": "1.0.1-beta.0",
15
+ "jsnext:source": "./src/index.ts",
16
+ "types": "./dist/types/index.d.ts",
17
+ "main": "./dist/js/node/index.js",
18
+ "module": "./dist/js/treeshaking/index.js",
19
+ "jsnext:modern": "./dist/js/modern/index.js",
20
+ "exports": {
21
+ ".": {
22
+ "jsnext:source": "./src/index.ts",
23
+ "default": "./dist/js/node/index.js"
24
+ }
25
+ },
26
+ "dependencies": {
27
+ "@babel/runtime": "^7.15.4",
28
+ "@modern-js/bff-runtime": "^1.2.3",
29
+ "@modern-js/utils": "^1.7.6",
30
+ "esbuild": "^0.14.38",
31
+ "esbuild-register": "^3.3.3",
32
+ "http-errors": "^2.0.0",
33
+ "koa-compose": "^4.1.0",
34
+ "reflect-metadata": "^0.1.13"
35
+ },
36
+ "devDependencies": {
37
+ "@scripts/build": "0.0.0",
38
+ "@scripts/jest-config": "0.0.0",
39
+ "@types/jest": "^27",
40
+ "@types/koa-compose": "^3.2.5",
41
+ "@types/node": "^14",
42
+ "jest": "^27",
43
+ "type-fest": "^2.13.0",
44
+ "typescript": "^4",
45
+ "zod": "^3.17.3"
46
+ },
47
+ "peerDependencies": {
48
+ "zod": "^3.17.3"
49
+ },
50
+ "modernConfig": {
51
+ "output": {
52
+ "packageMode": "node-js"
53
+ }
54
+ },
55
+ "publishConfig": {
56
+ "registry": "https://registry.npmjs.org/",
57
+ "access": "public",
58
+ "types": "./dist/types/index.d.ts"
59
+ },
60
+ "wireit": {
61
+ "build": {
62
+ "command": "modern build",
63
+ "files": [
64
+ "src/**/*",
65
+ "tsconfig.json",
66
+ "package.json"
67
+ ],
68
+ "output": [
69
+ "dist/**/*"
70
+ ]
71
+ },
72
+ "test": {
73
+ "command": "jest --passWithNoTests",
74
+ "files": [
75
+ "src/**/*",
76
+ "tsconfig.json",
77
+ "package.json",
78
+ "tests/**/*"
79
+ ],
80
+ "output": []
81
+ }
82
+ },
83
+ "scripts": {
84
+ "new": "modern new",
85
+ "build": "wireit",
86
+ "test": "wireit"
87
+ },
88
+ "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
89
+ }