- Node.js
- npm
- Docker
Clone the repo and install the dependencies:
npm installSetup the .env file as below if you will going to use the docker-compose file from the repo:
DATABASE_URL=postgresql://user:[email protected]:5432/todo
ACCESS_KEY=access
REFRESH_KEY=refreshStart the docker containers to run a postgres locally:
docker compose up -dRun the migrations to create the tables:
npx drizzle-kit pushRun the server with the following command:
npm run devRun lint:
npm run lintRun tests:
npm run testIn order to run the integration test, you need to start the test server:
npm run dev:testThen you can run the integration tests:
npm run test:integrationTo run the application using Docker:
docker build --platform linux/amd64 -t todo-api .
docker run -p 4000:4000 todo-apiYou might need to create the user in the database in order to test it below:
Sign In:
curl --location 'http://localhost:4000/graphql' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation signIn($input: SignInDAO!) {\n signIn(input: $input) {\n accessToken\n }\n}","variables":{"input":{"username":"username","password":"password"}}}'Create Task:
curl --location 'http://localhost:4000/graphql' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation($input: CreateTaskDAO!) {\n createTask(input: $input) {\n id\n title\n description\n status\n }\n}","variables":{"input":{"title":"Task 1","description":"Some random description","status":"todo"}}}'Update Task:
curl --location 'http://localhost:4000/graphql' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation($updateTaskId: ID!, $input: UpdateTaskDAO!) {\n updateTask(id: $updateTaskId, input: $input) {\n id\n title\n description\n status\n }\n}","variables":{"updateTaskId":1,"input":{"status":"inProgress"}}}'List of Tasks:
curl --location 'http://localhost:4000/graphql' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{"query":"query {\n tasks {\n totalCount\n items {\n id\n title\n description\n status\n }\n }\n}","variables":{}}'- Host
- CI to run integration tests
- Improve local development with DB Seed