Skill test abishar
A simple RESTFUL API that provides endpoints to batch insert data.

Prerequisites
Installation
- Clone this repository.
- Duplicate .env.example file to
.env
file and change the variable value
with your desired value.
- Next, run below command to migrate the database.
migrate -database "postgres://{DB_USERNAME}:{DB_PASSWORD}}@{DB_HOST}:{DB_PORT}/{DB_NAME}?sslmode=disable" -path db/migrations up
NOTE: Replace {DB_USERNAME}, {DB_PASSWORD}, {DB_HOST}
, etc with the corresponding value in your .env
file.
- Then run this command to synchronize all the dependencies.
go mod tidy
- Finally, run the project.
go run .
Usage
Do the post request as below:
curl -X POST \
'localhost:{PORT}/sales' \
--header 'Accept: */*' \
--header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \
--header 'Content-Type: application/json' \
--data-raw '{
"request_id": 12345,
"data": [
{
"id": 0,
"customer": "Vazquez Rowland",
"quantity": 1,
"price": 10,
"timestamp": "2022-01-01 22:10:44"
}
]
}'
NOTE: Replace the {PORT}
with your defined PORT
value in your .env
file.
Hanif Naufal – @Digisata – hnaufal123@gmail.com
Distributed under the MIT license. See LICENSE for more information.
Contributing
- Fork this repository.
- Create your own branch (
git checkout -b fooBar
).
- Commit your changes (
git commit -am 'Add some fooBar'
).
- Push to the branch (
git push origin fooBar
).
- Create your awesome Pull Request.