@modern-js/bff-runtime 1.2.1 → 1.2.2

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.
package/.eslintrc.js ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['@modern-js'],
4
+ parserOptions: {
5
+ tsconfigRootDir: __dirname,
6
+ project: ['./tsconfig.json'],
7
+ },
8
+ };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @modern-js/bff-runtime
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 6cffe99d: chore:
8
+ remove react eslint rules for `modern-js` rule set.
9
+ add .eslintrc for each package to speed up linting
10
+ - 60f7d8bf: feat: add tests dir to npmignore
11
+ - Updated dependencies [6cffe99d]
12
+ - Updated dependencies [04ae5262]
13
+ - Updated dependencies [60f7d8bf]
14
+ - @modern-js/server-utils@1.2.3
15
+
3
16
  ## 1.2.1
4
17
 
5
18
  ### Patch Changes
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.1",
14
+ "version": "1.2.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7",
32
- "@modern-js/server-utils": "^1.2.1",
32
+ "@modern-js/server-utils": "^1.2.3",
33
33
  "farrow-api": "^1.10.8",
34
34
  "farrow-http": "^1.10.8",
35
35
  "farrow-pipeline": "^1.10.6",
@@ -48,8 +48,7 @@
48
48
  },
49
49
  "publishConfig": {
50
50
  "registry": "https://registry.npmjs.org/",
51
- "access": "public",
52
- "types": "./dist/types/index.d.ts"
51
+ "access": "public"
53
52
  },
54
53
  "scripts": {
55
54
  "new": "modern new",
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- };
@@ -1,133 +0,0 @@
1
- import assert from 'assert';
2
- import { baseMatch } from '../src/match';
3
- import { match, isHandler, isSchemaHandler, Any } from '../src';
4
-
5
- describe('match', () => {
6
- it('should work well', async () => {
7
- const foo = baseMatch(
8
- {
9
- request: { data: { foo: Number } },
10
- response: { foo: String },
11
- },
12
- input => ({ foo: String(input.data.foo) }),
13
- );
14
-
15
- const result = await foo({ data: { foo: 0 } });
16
-
17
- expect(result.type).toBe('HandleSuccess');
18
- assert(result.type === 'HandleSuccess');
19
- expect(result.value.foo).toBe('0');
20
- });
21
-
22
- it('should support all file in request', async () => {
23
- const foo = baseMatch(
24
- {
25
- request: {
26
- data: { foo: Number },
27
- params: { id: String },
28
- query: { key: String },
29
- headers: { 'Context-Length': String },
30
- cookies: { sid: String },
31
- },
32
- response: { foo: String },
33
- },
34
- input => ({ foo: String(input.data.foo) }),
35
- );
36
-
37
- const result = await foo({
38
- data: { foo: 0 },
39
- params: { id: 'foo' },
40
- query: { key: 'foo' },
41
- headers: { 'Context-Length': '100' },
42
- cookies: { sid: 'sid0' },
43
- });
44
-
45
- expect(result.type).toBe('HandleSuccess');
46
- assert(result.type === 'HandleSuccess');
47
- expect(result.value.foo).toBe('0');
48
- });
49
-
50
- it('should support body,formData,formUrlencoded when data is not exist', () => {
51
- const foo = baseMatch(
52
- {
53
- request: {},
54
- response: Any,
55
- },
56
- input => input,
57
- );
58
- foo({ body: 'test' });
59
- foo({ formData: { foo: 'test' } as any });
60
- foo({ formUrlencoded: { foo: 'test' } });
61
- });
62
-
63
- it('should fail when input does not match schema', async () => {
64
- const foo = baseMatch(
65
- {
66
- request: { data: { foo: Number } },
67
- response: { foo: String },
68
- },
69
- input => ({ foo: String(input.data.foo) }),
70
- );
71
-
72
- const result = await foo({ data: { foo: true as any } });
73
-
74
- expect(result.type).toBe('InputValidationError');
75
- assert(result.type === 'InputValidationError');
76
- expect(result.message).toBe('path: ["data","foo"]\ntrue is not a number');
77
- });
78
-
79
- it('should fail when output does not match schema', async () => {
80
- const foo = baseMatch(
81
- {
82
- request: { data: { foo: Number } },
83
- response: { foo: String },
84
- },
85
- input => ({ foo: input.data.foo } as any),
86
- );
87
-
88
- const result = await foo({ data: { foo: 0 } });
89
-
90
- expect(result.type).toBe('OutputValidationError');
91
- assert(result.type === 'OutputValidationError');
92
- expect(result.message).toBe('path: ["foo"]\n0 is not a string');
93
- });
94
-
95
- it('should type nest', async () => {
96
- const getFoo = (input: { foo: string }) => input;
97
-
98
- const foo = match(
99
- {
100
- request: { data: { foo: Number } },
101
- response: { foo: String },
102
- },
103
- input => ({ foo: input.data.foo } as any),
104
- );
105
-
106
- const result = await foo({ data: { foo: 0 } });
107
-
108
- getFoo(result);
109
- });
110
-
111
- it('isSchemaHandler', () => {
112
- const foo = baseMatch(
113
- {
114
- request: { data: { foo: Number } },
115
- response: { foo: String },
116
- },
117
- input => ({ foo: String(input.data.foo) }),
118
- );
119
-
120
- expect(isSchemaHandler(foo)).toBeTruthy();
121
- expect(isSchemaHandler({})).toBeFalsy();
122
- expect(isSchemaHandler('test')).toBeFalsy();
123
- expect(isSchemaHandler(null)).toBeFalsy();
124
- });
125
-
126
- it('isHandler', () => {
127
- // eslint-disable-next-line @typescript-eslint/no-empty-function
128
- expect(isHandler(() => {})).toBeTruthy();
129
- expect(isHandler({})).toBeFalsy();
130
- expect(isHandler('test')).toBeFalsy();
131
- expect(isHandler(null)).toBeFalsy();
132
- });
133
- });
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {}
9
- }
10
- }