Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vomnes/c2fyymfjyw5l
https://github.com/vomnes/c2fyymfjyw5l
docker docker-compose golang javaspring junit5 mongodb unit-testing
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/vomnes/c2fyymfjyw5l
- Owner: vomnes
- Created: 2019-12-25T23:50:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-14T17:56:24.000Z (almost 2 years ago)
- Last Synced: 2024-11-22T17:17:52.196Z (3 months ago)
- Topics: docker, docker-compose, golang, javaspring, junit5, mongodb, unit-testing
- Language: Go
- Homepage:
- Size: 14.7 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# c2FyYmFjYW5l
## Launch the service
Docker is required.**Create the docker images:**
`sh create-docker-images.sh`
or
`docker-compose build`**Build and run the docker containers:**
`sh run.sh`
or
`docker-compose up`
This command run the unit tests for each microservice and then launch it.## CSV Extractor
This microservice is an API that use :
- Java Spring
- Junit 5 for the tests#### POST - /uploadCSV
This route allows to extract a contact list from a CSV.Take as parameter in the **'form-data'** body an item named **'file'** that contains a file with the contact list :
- A file must be selected
- This file must be a CSV type
- The CSV delimiters handled are ";" and ","
- The CSV file must at least contains a valid 'email' or 'phone number'
- Field names are not necessaryOther details :
- If a email address is found his value is stored in 'email'
- If a phone number is found his value is stored in 'phoneNumber'
- If an element in email row is found but his content is not an email this data is cleared
- If an element in 'n° de mobile' row is found but his content is not an french phone number this data is cleared
- Content that doesn't have a field name is affected to 'col{rowIndex}' field nameThe extracted data will be formatted in JSON and send to the route 'POST /v1/contacts' of the Manage Contacts microservice.
If you want to get the formatted JSON in the HTTP response (no connection with 'POST /v1/contacts') you just need to add in the request header `Content-Test: 'true'`.## Manage Contacts
This microservice is an API that use :
- Golang
- Unit testing with the Golang standard library
- MongoDB (3.4.6) for the database containing the collections `Contacts` and `FieldNames`#### POST - /v1/contacts
This route allows to store the contact list in the body in the mongodb database.```
JSON Body :
[
{
"phoneNumber" string,
"email" string,
"xFieldName" string,
...
}
...
]
```Details :
- Email are cleared if invalid
- PhoneNumber must be french number to be valid else cleared
- PhoneNumber are formatted for insertion with +33
Not inserted if :
- Email or PhoneNumber exists already in the database
- Email & PhoneNumber are empty (or invalid for email)
- New contact doesn't contains an email or phoneNumber
If failed to insert contacts the list of those contact is returned in the response JSONReturn HTTP Code 201 Status Created for success
## Database - MongoDB
The name of the database in MongoDB is *sarbacanes_contacts*.### Collections
#### Contacts
```
{
"_id" string,
"email" string,
"phoneNumber" string,
"createdat" time,
"updatedat" time,
"informations" [
{
"fieldName_id": string,
"value": string
}
...
]
}
```#### FieldNames
```
{
"_id": string,
"captionName": string
}
```