This project contains a Golang database implementation that serves as an example to how someone might look at implementing docker / postgres / JWT etc.
The API is currently live on https://www.api.chadchillbro.com/
This API defaults to port 8080 for the app, and 5432 with the postgres. Ensure these ports are not in use. Also make sure for some really weird reason you dont have an env variable called APP_ENV="production"... The payloads are to be sent via a raw transaction, not URL encoded etc.
From the project root
$ docker-compose up
Test can be run locally
$ go test ./...
Endpoint to create an user row in postgres db.where email
is an unique key in the database. The payload should have the following fields:
{
"email": "[email protected]",
"password": "badPassword",
"firstName": "Chad",
"lastName": "Chillerton"
}
The response body returns a JWT on success that can be used for other endpoints:
{
"token": "some_jwt_token"
}
Endpoint to log an user in.
The payload:
{
"email": "[email protected]",
"password": "badPassword"
}
The response body returns a JWT on success that can be used for other endpoints:
{
"token": "some_jwt_token"
}
Endpoint to retrieve a json of all users. This endpoint requires a valid x-authentication-token
header to be passed in with the request.
The response:
{
"users": [
{
"email": "[email protected]",
"firstName": "Optimus",
"lastName": "Prime"
}
]
}
Endpoint to update the current user firstName
or lastName
only. This endpoint requires a valid x-authentication-token
header to be passed in and it should only update the user of the JWT being passed in.
The payload:
{
"firstName": "NewFirstName",
"lastName": "NewLastName"
}
- Update Documentation
- Add deployment for succesful Travis builds / tests
- Create some sort of deployment controls
- Make script or methodology for updating api
- Attempt to make Go application images smaller(delete everything except executable in the dockerfile?)
- Make docker - compose more robust, include always restart flags
- Add more logs for $docker container logs
- Create script to migrate database in the event of updating production server
- Create scripts for doing option 2/3 of update production
- Figure out why ssh into database is not working or showing tables
- Fix issue where deploy script only works if ther is currently an active app and db working....
- Implement rate limit for ip
- Add automated testing for docker-compose updates
- Build exec watcher to auto docker-compose build
- Write postman tests