1.1.3 • Published 3 years ago

@sleegle/sthore v1.1.3

Weekly downloads
20
License
MIT
Repository
github
Last release
3 years ago

alt text

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

  1. 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"
        }
      ]
    }
  ]
}
  1. Run sthore command

  2. Your js files are generated

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago