CARGO NFT BACKEND
FE integration:
How to start project ?
To start backend service, you need to install docker and golang-migrate first.
- Install golang-migrate
brew install golang-migrate
- Create dockerdb container
make postgres
- Create database instance
make createdb
We also provide a cli to drop database if you need to refresh project
make dropdb
- Migrate schema and master data
make migrateup
- Generate sqlc
make sqlc
- Start web service
make server
Usefull commands
Migrations:
- Create migrations:
make migrations name={ARGS}
- Migration up:
make migrationup
- Migration down:
make migrationdown
Deployment:
- Docker build:
make docker.build
- Push docker image to registry:
make docker.push
- Deploy to staging env:
make deploy.staging
Authorization
Library: https://github.com/casbin/casbin
Model:
permission
: define all system permissions. Permission can have type
or not.
Currently, there is only one type
, this is CRUD
, it represents 4 action: read, update, create, delete with
following bitmask. In contrast, if type
is null
, this means action is can
.
action | bit |
---|
create | 8 // 0b1000 |
read | 4 // 0b0100 |
update | 2 // 0b0010 |
delete | 1 // 0b0001 |
CONVENTION