mock-config-server 3.7.0 → 3.7.1

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,2 +1,2 @@
1
- export * from './user';
2
- export * from './users';
1
+ export * from './user';
2
+ export * from './users';
@@ -1,37 +1,37 @@
1
- import type { GraphQLRequestConfig } from 'mock-config-server';
2
-
3
- export const getUserQuery: GraphQLRequestConfig = {
4
- operationName: 'getUser',
5
- operationType: 'query',
6
- routes: [
7
- {
8
- data: { id: 1, emoji: '🎉' }
9
- },
10
- {
11
- data: { id: 2, emoji: '🔥' },
12
- entities: {
13
- variables: {
14
- id: 2
15
- }
16
- }
17
- }
18
- ]
19
- };
20
-
21
- export const createUserMutation: GraphQLRequestConfig = {
22
- operationName: 'createUser',
23
- operationType: 'mutation',
24
- routes: [
25
- {
26
- data: { id: 1, emoji: '🎉' }
27
- },
28
- {
29
- data: { id: 2, emoji: '🔥' },
30
- entities: {
31
- variables: {
32
- emoji: '🔥'
33
- }
34
- }
35
- }
36
- ]
37
- };
1
+ import type { GraphQLRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUserQuery: GraphQLRequestConfig = {
4
+ operationName: 'getUser',
5
+ operationType: 'query',
6
+ routes: [
7
+ {
8
+ data: { id: 1, emoji: '🎉' }
9
+ },
10
+ {
11
+ data: { id: 2, emoji: '🔥' },
12
+ entities: {
13
+ variables: {
14
+ id: 2
15
+ }
16
+ }
17
+ }
18
+ ]
19
+ };
20
+
21
+ export const createUserMutation: GraphQLRequestConfig = {
22
+ operationName: 'createUser',
23
+ operationType: 'mutation',
24
+ routes: [
25
+ {
26
+ data: { id: 1, emoji: '🎉' }
27
+ },
28
+ {
29
+ data: { id: 2, emoji: '🔥' },
30
+ entities: {
31
+ variables: {
32
+ emoji: '🔥'
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ };
@@ -1,14 +1,14 @@
1
- import type { GraphQLRequestConfig } from 'mock-config-server';
2
-
3
- export const getUsersQuery: GraphQLRequestConfig = {
4
- operationName: 'getUsers',
5
- operationType: 'query',
6
- routes: [
7
- {
8
- data: [
9
- { id: 1, emoji: '🎉' },
10
- { id: 2, emoji: '🔥' }
11
- ]
12
- }
13
- ]
14
- };
1
+ import type { GraphQLRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUsersQuery: GraphQLRequestConfig = {
4
+ operationName: 'getUsers',
5
+ operationType: 'query',
6
+ routes: [
7
+ {
8
+ data: [
9
+ { id: 1, emoji: '🎉' },
10
+ { id: 2, emoji: '🔥' }
11
+ ]
12
+ }
13
+ ]
14
+ };
@@ -1,2 +1,2 @@
1
- export * from './user';
2
- export * from './users';
1
+ export * from './user';
2
+ export * from './users';
@@ -1,37 +1,37 @@
1
- import type { RestRequestConfig } from 'mock-config-server';
2
-
3
- export const getUserRequest: RestRequestConfig = {
4
- method: 'get',
5
- path: '/users/:id',
6
- routes: [
7
- {
8
- data: { id: 1, emoji: '🎉' }
9
- },
10
- {
11
- data: { id: 2, emoji: '🔥' },
12
- entities: {
13
- params: {
14
- id: 2
15
- }
16
- }
17
- }
18
- ]
19
- };
20
-
21
- export const postUserRequest: RestRequestConfig = {
22
- method: 'post',
23
- path: '/users',
24
- routes: [
25
- {
26
- data: { id: 1, emoji: '🎉' }
27
- },
28
- {
29
- data: { id: 2, emoji: '🔥' },
30
- entities: {
31
- body: {
32
- emoji: '🔥'
33
- }
34
- }
35
- }
36
- ]
37
- };
1
+ import type { RestRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUserRequest: RestRequestConfig = {
4
+ method: 'get',
5
+ path: '/users/:id',
6
+ routes: [
7
+ {
8
+ data: { id: 1, emoji: '🎉' }
9
+ },
10
+ {
11
+ data: { id: 2, emoji: '🔥' },
12
+ entities: {
13
+ params: {
14
+ id: 2
15
+ }
16
+ }
17
+ }
18
+ ]
19
+ };
20
+
21
+ export const postUserRequest: RestRequestConfig = {
22
+ method: 'post',
23
+ path: '/users',
24
+ routes: [
25
+ {
26
+ data: { id: 1, emoji: '🎉' }
27
+ },
28
+ {
29
+ data: { id: 2, emoji: '🔥' },
30
+ entities: {
31
+ body: {
32
+ emoji: '🔥'
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ };
@@ -1,14 +1,14 @@
1
- import type { RestRequestConfig } from 'mock-config-server';
2
-
3
- export const getUsersRequest: RestRequestConfig = {
4
- path: '/users',
5
- method: 'get',
6
- routes: [
7
- {
8
- data: [
9
- { id: 1, emoji: '🎉' },
10
- { id: 2, emoji: '🔥' }
11
- ]
12
- }
13
- ]
14
- };
1
+ import type { RestRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUsersRequest: RestRequestConfig = {
4
+ path: '/users',
5
+ method: 'get',
6
+ routes: [
7
+ {
8
+ data: [
9
+ { id: 1, emoji: '🎉' },
10
+ { id: 2, emoji: '🔥' }
11
+ ]
12
+ }
13
+ ]
14
+ };
@@ -1,2 +1,2 @@
1
- export * from './user';
2
- export * from './users';
1
+ export * from './user';
2
+ export * from './users';
@@ -1,37 +1,37 @@
1
- import type { GraphQLRequestConfig } from 'mock-config-server';
2
-
3
- export const getUserQuery: GraphQLRequestConfig = {
4
- operationName: 'getUser',
5
- operationType: 'query',
6
- routes: [
7
- {
8
- data: { id: 1, emoji: '🎉' }
9
- },
10
- {
11
- data: { id: 2, emoji: '🔥' },
12
- entities: {
13
- variables: {
14
- id: 2
15
- }
16
- }
17
- }
18
- ]
19
- };
20
-
21
- export const createUserMutation: GraphQLRequestConfig = {
22
- operationName: 'createUser',
23
- operationType: 'mutation',
24
- routes: [
25
- {
26
- data: { id: 1, emoji: '🎉' }
27
- },
28
- {
29
- data: { id: 2, emoji: '🔥' },
30
- entities: {
31
- variables: {
32
- emoji: '🔥'
33
- }
34
- }
35
- }
36
- ]
37
- };
1
+ import type { GraphQLRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUserQuery: GraphQLRequestConfig = {
4
+ operationName: 'getUser',
5
+ operationType: 'query',
6
+ routes: [
7
+ {
8
+ data: { id: 1, emoji: '🎉' }
9
+ },
10
+ {
11
+ data: { id: 2, emoji: '🔥' },
12
+ entities: {
13
+ variables: {
14
+ id: 2
15
+ }
16
+ }
17
+ }
18
+ ]
19
+ };
20
+
21
+ export const createUserMutation: GraphQLRequestConfig = {
22
+ operationName: 'createUser',
23
+ operationType: 'mutation',
24
+ routes: [
25
+ {
26
+ data: { id: 1, emoji: '🎉' }
27
+ },
28
+ {
29
+ data: { id: 2, emoji: '🔥' },
30
+ entities: {
31
+ variables: {
32
+ emoji: '🔥'
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ };
@@ -1,14 +1,14 @@
1
- import type { GraphQLRequestConfig } from 'mock-config-server';
2
-
3
- export const getUsersQuery: GraphQLRequestConfig = {
4
- operationName: 'getUsers',
5
- operationType: 'query',
6
- routes: [
7
- {
8
- data: [
9
- { id: 1, emoji: '🎉' },
10
- { id: 2, emoji: '🔥' }
11
- ]
12
- }
13
- ]
14
- };
1
+ import type { GraphQLRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUsersQuery: GraphQLRequestConfig = {
4
+ operationName: 'getUsers',
5
+ operationType: 'query',
6
+ routes: [
7
+ {
8
+ data: [
9
+ { id: 1, emoji: '🎉' },
10
+ { id: 2, emoji: '🔥' }
11
+ ]
12
+ }
13
+ ]
14
+ };
@@ -1,2 +1,2 @@
1
- export * from './user';
2
- export * from './users';
1
+ export * from './user';
2
+ export * from './users';
@@ -1,37 +1,37 @@
1
- import type { RestRequestConfig } from 'mock-config-server';
2
-
3
- export const getUserRequest: RestRequestConfig = {
4
- method: 'get',
5
- path: '/users/:id',
6
- routes: [
7
- {
8
- data: { id: 1, emoji: '🎉' }
9
- },
10
- {
11
- data: { id: 2, emoji: '🔥' },
12
- entities: {
13
- params: {
14
- id: 2
15
- }
16
- }
17
- }
18
- ]
19
- };
20
-
21
- export const postUserRequest: RestRequestConfig = {
22
- method: 'post',
23
- path: '/users',
24
- routes: [
25
- {
26
- data: { id: 1, emoji: '🎉' }
27
- },
28
- {
29
- data: { id: 2, emoji: '🔥' },
30
- entities: {
31
- body: {
32
- emoji: '🔥'
33
- }
34
- }
35
- }
36
- ]
37
- };
1
+ import type { RestRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUserRequest: RestRequestConfig = {
4
+ method: 'get',
5
+ path: '/users/:id',
6
+ routes: [
7
+ {
8
+ data: { id: 1, emoji: '🎉' }
9
+ },
10
+ {
11
+ data: { id: 2, emoji: '🔥' },
12
+ entities: {
13
+ params: {
14
+ id: 2
15
+ }
16
+ }
17
+ }
18
+ ]
19
+ };
20
+
21
+ export const postUserRequest: RestRequestConfig = {
22
+ method: 'post',
23
+ path: '/users',
24
+ routes: [
25
+ {
26
+ data: { id: 1, emoji: '🎉' }
27
+ },
28
+ {
29
+ data: { id: 2, emoji: '🔥' },
30
+ entities: {
31
+ body: {
32
+ emoji: '🔥'
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ };
@@ -1,14 +1,14 @@
1
- import type { RestRequestConfig } from 'mock-config-server';
2
-
3
- export const getUsersRequest: RestRequestConfig = {
4
- path: '/users',
5
- method: 'get',
6
- routes: [
7
- {
8
- data: [
9
- { id: 1, emoji: '🎉' },
10
- { id: 2, emoji: '🔥' }
11
- ]
12
- }
13
- ]
14
- };
1
+ import type { RestRequestConfig } from 'mock-config-server';
2
+
3
+ export const getUsersRequest: RestRequestConfig = {
4
+ path: '/users',
5
+ method: 'get',
6
+ routes: [
7
+ {
8
+ data: [
9
+ { id: 1, emoji: '🎉' },
10
+ { id: 2, emoji: '🔥' }
11
+ ]
12
+ }
13
+ ]
14
+ };
@@ -15,17 +15,19 @@ const contextMiddleware = (server)=>{
15
15
  requestId += 1;
16
16
  request.id = requestId;
17
17
  request.timestamp = Date.now();
18
- const graphQLInput = (0, _helpers.getGraphQLInput)(request);
19
- var _graphQLInput_query;
20
- const graphQLQuery = (0, _helpers.parseQuery)((_graphQLInput_query = graphQLInput.query) !== null && _graphQLInput_query !== void 0 ? _graphQLInput_query : '');
21
- if (graphQLInput.query && graphQLQuery) {
22
- request.graphQL = {
23
- operationType: graphQLQuery.operationType,
24
- operationName: graphQLQuery.operationName,
25
- query: graphQLInput.query,
26
- variables: graphQLInput.variables
27
- };
28
- return next();
18
+ if (request.method === 'GET' || request.method === 'POST') {
19
+ const graphQLInput = (0, _helpers.getGraphQLInput)(request);
20
+ var _graphQLInput_query;
21
+ const graphQLQuery = (0, _helpers.parseQuery)((_graphQLInput_query = graphQLInput.query) !== null && _graphQLInput_query !== void 0 ? _graphQLInput_query : '');
22
+ if (graphQLInput.query && graphQLQuery) {
23
+ request.graphQL = {
24
+ operationType: graphQLQuery.operationType,
25
+ operationName: graphQLQuery.operationName,
26
+ query: graphQLInput.query,
27
+ variables: graphQLInput.variables
28
+ };
29
+ return next();
30
+ }
29
31
  }
30
32
  request.graphQL = null;
31
33
  return next();
@@ -39,7 +39,7 @@ const notFoundMiddleware = (server, mockServerConfig)=>{
39
39
  });
40
40
  }
41
41
  let graphqlRequestSuggestions = [];
42
- if (graphql && (0, _helpers.parseGraphQLRequest)(request)) {
42
+ if ((request.method === 'GET' || request.method === 'POST') && graphql && (0, _helpers.parseGraphQLRequest)(request)) {
43
43
  graphqlRequestSuggestions = (0, _helpers1.getGraphqlUrlSuggestions)({
44
44
  url,
45
45
  requestConfigs: graphqlRequestConfigs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mock-config-server",
3
- "version": "3.7.0",
3
+ "version": "3.7.1",
4
4
  "description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
5
5
  "author": {
6
6
  "name": "SIBERIA CAN CODE 🧊",