Last active
April 23, 2020 08:12
-
-
Save samuraitruong/c7a30210ae894c865ad462fdc91a2cc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement RestAPI server to allow you retrieve DVCH VN | |
## Database provided | |
- Mongo DB | |
mongodb+srv://user_ro:<password>@cluster0-b0cl8.gcp.mongodb.net/dvch?retryWrites=true&w=majority | |
- password: o7vv7XCpbHwJxwVW | |
This user is readonly user. it can't insert or update or delete any data from above database | |
## Database | |
- collection : items | |
- data row are like this: | |
``` | |
{"_id":{"$oid":"5ea0ce3e00ab447fb07eb7c8"},"type":"Thành phố","code":1,"name":"Hà Nội"} -> level 1 | |
{"_id":{"$oid":"5ea0ce3e00ab447fb07eb7c9"},"type":"Quận","code":1,"name":"Ba Đình","parent_id":{"$oid":"5ea0ce3e00ab447fb07eb7c8"}} -> level 2 | |
{"_id":{"$oid":"5ea0ce3e00ab447fb07eb7ca"},"code":1,"name":"Phúc Xá","type":"Phường","parent_id":{"$oid":"5ea0ce3e00ab447fb07eb7c9"}} => level 3 | |
``` | |
## API Endpoint | |
/api/v1/province | |
return all the provinces , also has filter by type and name | |
response | |
``` | |
[{ name: 'abc', type: 'type', code: 1}.....] | |
``` | |
- /api/v1/province/:name => return the province by name, list of all district it has | |
- /api/v1/province/:name/district => return all district belong to that province if match (filter breturny parent_id) | |
- /api/v1/district/?query="Txt" => return list of district that match with the query with case insensitive compare | |
- /api/v1/district/:name => return district info witayh list of wards it has | |
- api/v1/province/:provinName/district return all district belong to provine | |
- a /api/v1/district/:name/wards => return list of wards | |
-api/v1/ward/:id return ward id | |
- api/v1/search?keyword=xx&page=1&pageSize=50 => return all item with that match with search condition, with paging support, | |
### | |
use express | |
write the code with unit test | |
deploy to heroku | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment