product-keeper

module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2024 License: MIT

README

Run

Set env variables CONFIG_PATH and JWT_SECRET before run:

CONFIG_PATH=config/local.yaml
JWT_SECRET=qwerty
make run

After apply all migrations from folder migrations.

Examples

  • User registration:

    curl -X POST \
    -H "Content-Type: application/json" \
    -d '{"username":"${USERNAME?}","password":"${PASSWORD?}"}' \
    'http://localhost:8080/user/register'
    
  • Login:

    curl -X POST \
    -H "Content-Type: application/json" \
    -d '{"username":"${USERNAME?}","password":"${PASSWORD?}"}' \
    'http://localhost:8080/user/login'
    
  • Create a product:

    curl -X 'POST' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer ${TOKEN?}' \
    -d '{
    "name": "gopher1",
    "price": 42,
    "quantity": 42
    }' \
    'http://localhost:8080/product/add'
    
  • Get product by id:

    curl -X 'GET' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer ${TOKEN?}' \
    'http://localhost:8080/product/${ID?}
    
  • Update product by id:

    curl -X 'PUT' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer ${TOKEN?}' \
    -d '{
      "name": "gopher1",
      "price": 43,
      "quantity": 43
    }' \
    'http://localhost:8080/product/${ID?}'
    
  • Delete product by id:

    curl -X 'DELETE' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer ${TOKEN?}' \
    'http://localhost:8080/product/${ID?}'
    
  • Get all products:

    curl -X 'GET' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer ${TOKEN?}' \
    'http://localhost:8080/products?name=aaaaaaaaaaaa&sort_by=last_create'
    

Directories

Path Synopsis
cmd
product-keeper command
internal
app
mocks/auth
Package mockauth is a generated GoMock package.
Package mockauth is a generated GoMock package.
mocks/products
Package mockproducts is a generated GoMock package.
Package mockproducts is a generated GoMock package.
mocks/shared
Package mockshared is a generated GoMock package.
Package mockshared is a generated GoMock package.
pkg
jwt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL