https://github.com/ajinkyataranekar/contact-tracing-api
https://github.com/ajinkyataranekar/contact-tracing-api
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ajinkyataranekar/contact-tracing-api
- Owner: AjinkyaTaranekar
- Created: 2020-12-19T05:32:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-20T08:29:16.000Z (over 4 years ago)
- Last Synced: 2023-03-07T16:07:15.026Z (about 2 years ago)
- Language: Go
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Contact Tracing API
## List of Tasks Done
- Completion Percentage :- 75 %
- Total 5 endpoints are working.
- Make the server thread safe (I didn't know how to proceed with it in existing code, learned there are ways by locking function when one requestion is fetched but couldn't implemented it).
- Added pagination to the list endpoint.
- Add unit tests (added code, but failed to run)## How to run the application
1. Clone the application.
2. There is a dependency of mongo db driver which need to be imported before running the application. Please get the dependency through the following commands -
```shell
go get "go.mongodb.org/mongo-driver/mongo"
```3. To run the application, please use the following command -
```shell
go run .
```> Note: By default the port number its being run on is **5005**.
> Note: The Mongo DB is setup on my Azure VM.
## Endpoints Description
### Get All Users
```
URL - *http://localhost:5005/allUsers*
Method - GET
```### Get User By ID
```JSON
URL - *http://localhost:5005/user/*
Method - GET
```### Create User
```JSON
URL - *http://localhost:5005/user*
Method - POST
Body - (content-type = application/json)
{
"name":"John Doe",
"emailAddress":"[email protected]",
"phoneNo":"1234567890",
"dateOfBirth":"31-12-2019",
}
```### Create Contact
```JSON
URL - *http://localhost:5005/contacts*
Method - POST
Body - (content-type = application/json)
{
"_idOne":"5f83284980ndfs42",
"_idTwo":"5f83284980ndfs46"
}
```### List all primary contacts within the last 14 days of infection
```JSON
URL - *http://localhost:5005/contacts?user=&infection_timestamp=*
Method - GET
```## Test Driven Development Description
To run all the unit test cases, please do the following -
1. `go run .`
2. `go test -v`