Skip to content

Commit 55638a7

Browse files
authored
Merge pull request #76 from SkrzypMajster/refactor/ZN-411-improve-api-action-plop-commands
Refactor: [ZN-411] Improve API action plop commands
2 parents 130d0fb + 38de6e9 commit 55638a7

18 files changed

Lines changed: 225 additions & 82 deletions

.changeset/cold-pots-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-starter-boilerplate': minor
3+
---
4+
5+
refactor: [ZN-411] Improve API action plop commands

plop-templates/apiActions/apiActions.index.imports.hbs

Lines changed: 0 additions & 3 deletions
This file was deleted.

plop-templates/apiActions/apiActions.index.mutations.hbs

Lines changed: 0 additions & 2 deletions
This file was deleted.

plop-templates/apiActions/apiActions.index.queries.hbs

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { AxiosInstance } from 'axios';
22

3-
import { {{pascalCase name}}MutationArguments, {{pascalCase name}}MutationResponse } from './{{camelCase name}}.types';
3+
import {
4+
// MUTATION_TYPE_IMPORTS
5+
} from './{{camelCase name}}.types';
46

57
export const {{camelCase name}}Mutations = {
6-
{{camelCase name}}Mutation: (client: AxiosInstance) => async (body: {{pascalCase name}}MutationArguments) => {
7-
return (await client.post<{{pascalCase name}}MutationResponse>('/{{dashCase name}}', body)).data;
8-
},
8+
// MUTATION_FUNCTIONS_SETUP
99
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { AxiosInstance } from 'axios';
22

3-
import { Get{{pascalCase name}}QueryResponse } from './{{camelCase name}}.types';
3+
import {
4+
// QUERY_TYPE_IMPORTS
5+
} from './{{camelCase name}}.types';
46

57
export const {{camelCase name}}Queries = {
6-
get{{pascalCase name}}: (client: AxiosInstance) => async () => {
7-
return (await client.get<Get{{pascalCase name}}QueryResponse>('/{{dashCase name}}')).data;
8-
},
8+
// QUERY_FUNCTIONS_SETUP
99
};
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
export type {{pascalCase name}}MutationArguments = {
2-
3-
};
4-
5-
export type {{pascalCase name}}MutationResponse = {
6-
7-
};
8-
9-
export type {{pascalCase name}}MutationError = {
10-
11-
};
12-
13-
export type Get{{pascalCase name}}QueryResponse = {
14-
15-
};
16-
17-
export type Get{{pascalCase name}}QueryError = {
18-
19-
};
1+
// API_ACTION_TYPES
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{camelCase name}}: (client: AxiosInstance) => async (body: {{pascalCase name}}Payload) => {
2+
return (await client.{{method}}<{{pascalCase name}}Response>(`{{path}}`, body)).data;
3+
},
4+
$1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type {{pascalCase name}}Payload = {};
2+
3+
export type {{pascalCase name}}Response = {};
4+
5+
$1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{camelCase name}}: (client: AxiosInstance) => async ({}: {{pascalCase name}}Payload) => {
2+
return (await client.get<{{pascalCase name}}Response>(`{{path}}`)).data;
3+
},
4+
$1

0 commit comments

Comments
 (0)