Create a simple node service that provides provides some endpoints to allow the listing and updating of a list of countries and their population. This task should take 2-3 hours but don't worry if you aren't able to complete all items, just make sure to show your understanding of the core technologies we use.
- Fork this repo
- Create an endpoint that allows the listing of the countries in
src/api/country.ts
- Create an endpoint to fetch all of the countries sorted by their population
- Allow the populations to be updated
- Allow countries to be updated
- Allow countries to be deleted
- Add authentication using the
src/api/authenticate.ts
method - When you're done commit your code and create a pull request
Bonus points for
- Storing the data in Redis
- Allowing the app to be run from a docker-compose file
A basic project outline has been created to help you get started quickly but feel free to start from scratch if you have a preferred setup.
Feel free to use the internet including Google and Stackoverflow to help with the task
/api
/controllers
CountryController
REST routes for Country modelSesssionController
REST routes session (login, logout)
/repositories
/inmem
in-memory repositoriesCountryRepo
in-memory array adapter for country model
/redis
redis repositoriesCountryRepo
redis adapter for country model
/store
redis
redis store initialisation and configuration (used by redis repository)
A controller uses a repository to adapt and act on a particular data source
The redis repository could be made generic, assuming one RedisDB per model entity. Then we could store a registry of model -> RedisDB in some configuration.
Implementation has not been tested due to time constraints. This is just a challenge to demonstrate setting up a basic NodeJS API gateway/server with optional Redis store backing. The solution provided (see the code) should demonstrate capabilities.
If I was to test it fully with a test suite it would be too much effort for throw away code.
It was a great experience to use routing-controllers for a modern routing/controller experience, using decorators.
Hope you like it ;)