@sleegle/sthore
v1.1.3
Published
Generate a react store and services using redux, redux-saga and axios
Downloads
3
Readme
Sthore: Connect back-end API to react project with one command
Create your sthore-config file, put it in your project folder and run "sthore" command. BANG! it will create a Redux-Saga based store and generate API Services files for your project and you can fully customize it :) JUST ENJOY AND CHILL!
You can see Demo Here. Files src/stores and src/services folders are auto generated using sthore with sthore.config.json file in project root.
Installation
npm install @sleegle/sthore -g
or
yarn global add @sleegle/sthore
Usage
- Create your sthore.config.json file in project root
sthore.config.json template
{
"baseURL": "https://your_base_url", // Backend URL
"storesDir": "src/stores", // Stores folder direction
"servicesDir": "src/services", // Services folder direction
"stores": [
{
"name": "auth", // Store name
"actions": [ // Store actions
{
"name": "login", // Action name
"url": "/auth/login", // Action URL path
"method": "POST", // Action method
"storage": [ // Response data that you want to put it in local storage
"accessToken", // For example response is {"accessToken" : "...", efreshToken":"..."}
"refreshToken"
]
},
{
"name": "user",
"url": "/auth/user",
"method": "GET"
}
]
},
{
"name": "users",
"actions": [
{
"name": "getAll",
"url": "/users",
"method": "GET"
},
{
"name": "single",
"url": "/users/${id}", // If you have dynamic rams in your request,
// just put them in l like this "${param}
"method": "GET"
},
{
"name": "create",
"url": "/users",
"method": "POST"
},
{
"name": "update",
"url": "/users/${id}",
"method": "PUT"
},
{
"name": "remove",
"url": "/users/${id}",
"method": "DELETE"
}
]
}
]
}
Run sthore command
Your js files are generated