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.
- package/dist/bin/templates/ts/full/mock-requests/graphql/index.ts +2 -2
- package/dist/bin/templates/ts/full/mock-requests/graphql/user.ts +37 -37
- package/dist/bin/templates/ts/full/mock-requests/graphql/users.ts +14 -14
- package/dist/bin/templates/ts/full/mock-requests/rest/index.ts +2 -2
- package/dist/bin/templates/ts/full/mock-requests/rest/user.ts +37 -37
- package/dist/bin/templates/ts/full/mock-requests/rest/users.ts +14 -14
- package/dist/bin/templates/ts/graphql/mock-requests/index.ts +2 -2
- package/dist/bin/templates/ts/graphql/mock-requests/user.ts +37 -37
- package/dist/bin/templates/ts/graphql/mock-requests/users.ts +14 -14
- package/dist/bin/templates/ts/rest/mock-requests/index.ts +2 -2
- package/dist/bin/templates/ts/rest/mock-requests/user.ts +37 -37
- package/dist/bin/templates/ts/rest/mock-requests/users.ts +14 -14
- package/dist/src/core/middlewares/contextMiddleware/contextMiddleware.js +13 -11
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|