Boxmeup is a web and mobile application to help users keep track of what they have in their containers and how to find items in specific containers.
- Go >= 1.8.1 - For local development
- Docker 17.05.0-ce+ - For building and running in docker containers
cp docker-compose-dev.yml docker-compose.yml
Modify the docker compose file to suit needs.
docker-compose up -d
Bring your own mysql:
docker run -p 8080:8080 -e MYSQL_DSN=username:password@host:port/database cjsaylor/boxmeup-go
See .env.sample
for available configurations.
In order to run tests you will need to prepare your MySQL db by running the schema.sql
on the MySQL db you plan to use. If you use the docker provided MySQL image specified in the docker-compose.yml
file, you can run (on the running server):
# For local development
cat schema.sql | docker exec -i $(docker-compose ps -q mysql) mysql boxmeup -u boxmeup -pboxmeup
# For running unit tests
cat schema.sql | docker exec -i $(docker-compose ps -q mysql) mysql bmu_test -u root -psupersecret
Create a user:
curl -X POST \
http://localhost:8080/api/user/register \
-H 'content-type: multipart/form-data' \
-F [email protected] \
-F password=test1234
Obtain a json-webtoken (for use in subsequent requests to the API):
curl -X POST \
http://localhost:8080/api/user/login \
-H 'content-type: multipart/form-data' \
-F [email protected] \
-F password=test1234
This will yield a token:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MDQ5NTY5NjYsImlkIjoxLCJuYmYiOjE1MDQ1MjQ5NjYsInV1aWQiOiI5Yzk1MWIyNi05MGU1LTExZTctOTY0Ny0wMjQyYWMxMjAwMDIifQ.mgumlN4hQ5Wq3lmK1uiO9tAX21UOv7kLx5MYFI9KcdA"
}
Use the token in the header of further API requests (cURL example):
-H 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0OTU1NTI1MzgsImlkIjoyLCJuYmYiOjE0OTUxMjA1MzgsInV1aWQiOiJkMjU1MzY5OC0zYmRjLTExZTctYTU0NC0wODAwMjdkNGZkMjgifQ.ccSUP9AOrBplbwBs6e8dpTpePXHLipBSHvnYL1gFalw'
Dependencies are committed into the repo via godeps
, so no go install
required.
To build: go build -o server ./bin
To add a dependency:
go get godep
go get <pkg>
- Use it somewhere in the code.
godep save