This is the code base for backend server for the project MovieGenie
- Docker is a set of platform as a service product that uses OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.
- Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast and scalable network applications. Node.js is an open-source, cross-platform runtime environment for developing server-side and networking applications.
- Install Docker (Learn more about docker installation here)
- Enter on the project root directory
- Run the docker
docker-compose up -d
- Access phpmyadmin
your_ip:8183 Server: mysql Username: root/root Password: root/pass
- Access mysql on terminal(if needed)
docker exec -it mysql_server mysql -u root -p
Running Nodejs server
-
Install Nodejs (Download installer from here)
-
RUN :
npm install -
Now let’s run the app by running the following command :
node server.js.
We will build Rest Apis that can create, retrieve, update, delete and find users and movies by user_id.
The following table shows overview of the Rest APIs that will be exported
Run the below from postman by using
You will get an AuthToken when you login. Use the token in header of api call as {Authorization: AuthToken} for authorization.
| Methods | Urls | Actions | body |
|---|---|---|---|
| POST | /signup | Signup a new user | { user_id: "test_user1", password: "test_pass1", age: 20, gender: "Male", country: "Netherlands" } |
| POST | /login | Login using username and password | { user_id: "test_user1", password: "test_pass1" } |
| GET | /users/id/{user_id} | Get the user details | |
| PUT | /users/id/{user_id} | Update user details by id |
{password: "new_password"} |
| GET | /users/ | Get all user details | |
| DELETE | /users/id/{user_id} | Delete the user by user_id |
Tips:
After testing you can stop docker by docker stop mysql_server phpmyadmin
Confirm no container is running by docker ps -a