- Hexagonal Architecture (a.k.a Ports and Adapters)
- clone this repository
git clone git@github.com:vindecodex/togo.git
-
npm install
-
copy env variables
cp .env-sample .env
Note: (FOR NONE DOCKER ONLY) Please create 'togo' database before running the program
- npm run dev
NOTE: Also close other running mysql server from your computer it will conflict with the mysql docker image
docker-compose up --build
npm run test
or npm t
curl http://localhost:3000
Should output Welcome Togo
You cannot create a task If you don't have an account.
curl -d 'username=test&password=test' http://localhost:3000/user
Should output {"id":1,"username":"test","type":"BASIC"}
Get a token to allow creating task
curl -d 'username=test&password=test' http://localhost:3000/authenticate
Should output
{
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJ0ZXN0IiwidHlwZSI6IkJBU0lDIiwiaWF0IjoxNjU4MzkyOTk1fQ.6LOrSehIyFGhYRULxOYvm2o1jLVFFzv3gkHSaZqYfBM"
}
Copy Token value to be used for posting task
NOTE: Newly created user has only BASIC account which means you can only post 5 task per day, you can subscribe to PREMIUM to have 10 task per day.
curl -d 'task=YOUR_TASK' -H "Authorization: Bearer TOKEN_HERE" http://localhost:3000/todo
Should say true if added successfully
NOTE: You need to re-authenticate after upgrading.
curl -H "Authorization: Bearer TOKEN_HERE" http://localhost:3000/upgrade
Should say true if upgrade success.
curl http://localhost:3000/todo
curl http://localhost:3000/todo/user/{userId}