Just a simple test project with RESTful services build with node
- Node Package Manager should be installed on your OS. Please find more detail here: https://www.npmjs.com/get-npm
- Git project is downloaded
- Open Command Line and run 'npm install or npm i'. (This step is required only first time when you've downloaded project)
Run 'node index.js' in the Command Line or RunMe.bat if you are running it on Windows.
Now you can use test endpoints
By default this project works with hardcoded list of data that exist only during the session. Anyway, there is possibility to enable connection to real Mongo database
- Install MongoDb - https://www.mongodb.com/docs/manual/installation/
- Create a server on your local machine. In the first stage, I installed it as a server with no username or password.
- Create a database with a proper name. It can be any name, but at the moment in the configuration file it is equal to - "MoviesDb".
- (Optional) There may be JSON files in the Mongo-import_data folder that you can import to get initial data.
- Go to config folder and update required configuration: a) Update "mongoDB.uri". b) Set "useDatabase" to true
Note: I did a setup without authorization, but it maybe changed in the future. If you want to change, you may need to do it inside of the index.js file
Now you need to return to "How to run" step and start application
Swagger is available after node app is started by the following path: http://localhost:3000/api-docs/
In order to use enpoints, you need to login with help of Bearer token. Login button available in Swagger right up corner. In order to receive this token you need to send a request to Authorization endpoint by passing username and password parameters:
- Admin User Creds(All operations are available): testadmin/testadminpassword
- Regular User Creds(Only GET operations are available): test/testpassword
API tests were created with a libraries Axios, Jest
- Make sure you application is running
- Define BASE_URL in .env file (If you have changed default port)
- Open Command Line and run "npx jest" or "npm run test"
- Report output can be defined in jest.config.js file. By default in test-reports folder