This project is a solution to the challenge proposed by the coodesh, a REST API that uses a cron system to load data into a database and exposes it through the following endpoints:
GET /
: Return a message "REST Back-end Challenge 20201209 Running"PUT /users/:userId
: handle the made updates in a userDELETE /users/:userId
: remove the user from databaseGET /users/:userId
: get a userGET /users
: get a list of users
- Typescript
- ExpressJS
- Joi
- MongoDB
- Mongoose
- Node-Cron
- Node-Fetch
- Swagger
- EsLint
- Prettier
- Jest
- Supertest
- Docker
Use the package manager (all instructions are given based on npm
) to install the packages
npm install
1- Create a mongodb cluster
2- Create a .env.development file with the following keys:
URL_ROOT= 'http://localhost'
MAX_API_KEY_USAGE='30' #The max limit of API Key usage
PORT= 3333 #The port number server will be listening to, the default is 3333
CORN_SECOND = 0 #The preferred second to load the data from randomuser api
CORN_MINUTE = 0 #The preferred minute to load the data from randomuser api
CORN_HOUR = 0 #The preferred hour to load the data from randomuser api
MONGO_URL= "mongodb+srv://USER_NAME:[email protected]/coodesh-back-end?retryWrites=true&w=majority" #The URL to connect to the previously created cluster on step 1
3- Run the dev
script:
npm run dev
4- Go to the API docs through your browser, hit the endpoint /api-docs
to see all available endpoints and their specs
npm run test
The docker image can be found through through this link: https://hub.docker.com/repository/docker/josemarshall/user_cron
Pull requests are welcome; create a branch based on the develop
branch. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.