Made by Pedro Agulló, Jose Luis Aparicio and Miguel Torres
Hecho por Pedro Agulló, Jose Luis Aparicio and Miguel Torres
This project was proposed and deployed on the 5th week of GeeksHubs' Full Stack Developer Bootcamp
Este proyecto se propuso e implementó en la 5ª semana del Bootcamp Full Stack Developer de GeeksHubs
- Objetivo y tecnologías empleadas
- Index, routing y middleware
- Gestión de los Endpoints y la base de datos
- Conclusiones
The aim of the project was to develop an only-backend service for movies rental, with four defined areas:
- User Management
- Sign Up Endpoint
- Profile Endpoint
- Delete Account Endpoint
- Log In Endpoint
- Extra features: JWT; Admin and Client
- Movie/Product Management
- Search by Title Endpoint
- Search by Id Endpoint
- Display all Movies Endpoint
- Extra features: Filter by Actress/Actor;
Filter by Genre
- Order Management
- Create an Order Endpoint
- One Movie per Client
- Reception and Return Dates
- Extra features: Show all Orders (as Admin).
- Create an Order Endpoint
- Data Management
- Use of an ORM (Sequelize/MongoDB/MySQL)
The technologies we used were:
const express = require('express');
const app = express();
const port = 3006;
const router = require('./router');
app.use(router);
app.use(express.json());
app.listen(port, () => console.log(`Node server running on http://localhost:${port}`));
This js file:
- imported the Express.js library,
- saved its functionalities on "app",
- selected 3006 as the server's port and
- linked router.js.
Then, the router.js' and express.json()' functionalities were "used", or, we assume, loaded in memory.
app.listen() started a local node.js server that uses the 3006 port.
const router = require('express').Router();
const moviesRouter = require('./routes/moviesRouter.js');
const seriesRouter = require('./routes/seriesRouter.js');
router.use('/movies', moviesRouter);
router.use('/series', seriesRouter);
module.exports = router;
This js file imports the .Router() utility from Express.js, which is used to link the moviesRouter, customerRouter, orderRouter and loginRouter paths, and therefore their content, to index.js. In this sense, router.js is merely a link between the main application (index.js) to its dependencies.
Clone the project from here.
Install the needed dependencies (on Bash):
npm i
Install Postman from here.
In Postman:
- Add a new collection
- Use GET with the address: http://localhost:3006
Although we used 3006 as the default port, you can use another one of your choice.
To search top rated movies type the following:
http://localhost:3006/movies
To find movies by id just add a number after movies: POST
http://localhost:3006/movies
To find movies by title: POST
http://localhost:3006/movies/title
To search movies by genre: POST
http://localhost:3006/movies/genre
To search movies by actor/actress: POST
http://localhost:3006/movies/actor/
To get the list of all customers: GET
http://localhost:3006/customer
To find a customer by id: POST - {"customerId": "id"}
http://localhost:3006/customer/id
To find a customer by name: POST - {"name": "name"}
http://localhost:3006/customer/name
To create a new customer (this will check first if mail exists in the database): POST
http://localhost:3006/customer
To modify some attributes of the customer: PUT
http://localhost:3006/customer
To delete a customer: DELETE - {"id": "id"}
http://localhost:3006/customer
To log in: POST - {"mail": "yourmail", "password", "yourpassowrd"} http://localhost:3006/login/
Do not forget to save your token to postman Authorization "bearer token", to realize your actions.
To get the list of all orders: GET
http://localhost:3006/order
To find a order by id: POST - {"id": "id"}
http://localhost:3006/order/id
To find a order by city: POST - {"city": "city"}
http://localhost:3006/order/city
To create a new order: POST
http://localhost:3006/order/
To delete a order: DELETE - {"id": "id"}
http://localhost:3006/order
To obtain a list of top rated series:
http://localhost:3006/series/toprated
To find a tv show by id:
http://localhost:3006/series/id/ (your id)
To find a serie by their title:
http://localhost:3006/series/title/ (your title)
Obtaining series which will have at least one episode aired in the next seven day:
http://localhost:3006/series/ontheair7/
Obtaining series which are screened on theaters:
http://localhost:3006/series/screenedtheater/
El objetivo del proyecto es desarrollar un servicio (solo la parte backend) para alquiler de películas, con cuatro áreas definidas:
- Gestión de Usuarios
- Endpoint para Darse de Alta
- Endpoint para mostart Información de la Cuenta
- Endpoint para Darse de Baja
- Endpoint para Iniciar Sesión
- Características extra: JWT; Admin y Cliente
- Gestión de Películas/Productos
- Endpoint para Búsqueda por Título
- Endpoint para buscar por Id
- Endpoint para Mostrar todas las Películas
- Características extra: Filtrar por Actriz/Actor;
Filtrar por Género
- Gestión de los Pedidos
- Endpoint para Crear un Pedido
- Una única Película por Cliente
- Fechas de Recepción y de Devolución
- Características extra: Mostrar todos los Pedidos (solo para el Admin)
- Endpoint para Crear un Pedido
- Gestión de Datos
- Emplear un ORM (Sequelize/MongoDB/MySQL)
Las tecnologías empleadas fueron:
const express = require('express');
const app = express();
const port = 3006;
const router = require('./router');
app.use(router);
app.use(express.json());
app.listen(port, () => console.log(`Node server running on http://localhost:${port}`));
Este archivo js:
- importó la librería Express.js,
- guardó sus herramientas en "app",
- seleccionó 3006 como el puerto para el servidor y
- linked router.js.
- enlazó con router.js
Entonces, las herramientras de router.js y de express.json fueron "usadas", o, asumimos, guardadas en memoria.
app.listen() lanzó un servidor local node.js que emplea el puerto 3006.
const router = require('express').Router();
const moviesRouter = require('./routes/moviesRouter.js');
const seriesRouter = require('./routes/seriesRouter.js');
router.use('/movies', moviesRouter);
router.use('/series', seriesRouter);
module.exports = router;
Este archivo js importa la herramienta .Router() desde Express.js, la cual emplea para enlazar las rutas de moviesRouter, loginRouter, orderRouter y customerRouter, y por tanto su contenido, con index.js. En este sentido, router.js es un mero enlace entre la aplicación principal (index.js) con sus dependencias.
Clonar el proyecto desde aquí.
Instalar dependencias (desde Bash):
npm i
Instalar Postman desde aquí.
En Postman:
- Crea una nueva colección
- Emplea GET con la dirección: http://localhost:3006
Aunque nosotros hemos usado el puerto 3006, se puede utilizar cualquier otro a voluntad.
Búsqueda de películas mejor valoradas
Búsqueda de películas por id POST
http://localhost:3006/movies
Búsqueda de películas por título POST
http://localhost:3006/movies/title
Búsqueda de películas por género POST
http://localhost:3006/movies/genre
Búsqueda de películas por actor/actriz POST
http://localhost:3006/movies/actor/
Obtener una lista de todos los clientes GET
http://localhost:3006/customer
Búsqueda de cliente por id POST - {"customerId": "id"}
http://localhost:3006/customer/id
Búsqueda de cliente por nombre POST - {"name": "name"}
http://localhost:3006/customer/name
Crear un nuevo usuario (comprobará primero si el email ya está registrado) POST
http://localhost:3006/customer
Modificar datos del cliente PUT
http://localhost:3006/customer
Eliminar cliente DELETE - {"id": "id"}
http://localhost:3006/customer
Login POST - {"mail": "yourmail", "password", "yourpassowrd"} http://localhost:3006/login/
No olvidar almacenar el token en Authorization/Bearer Token!
Listar todos los pedidos GET
Búsqueda de pedido por id POST - {"id": "id"}
http://localhost:3006/order/id
Búsqueda de pedido por ciudad POST - {"city": "city"}
http://localhost:3006/order/city
Crear nuevo pedido POST
http://localhost:3006/order/
Borrar pedido DELETE - {"id": "id"}
http://localhost:3006/order
Listar series mejor valoradas
http://localhost:3006/series/toprated
Búsqueda de series por id
http://localhost:3006/series/id/ (your id)
Búsqueda de series por título
http://localhost:3006/series/title/ (your title)
Listar series que serán emitidas en los próximos siete días
http://localhost:3006/series/ontheair7/
Listar series que serán representadas en cines o teatros
http://localhost:3006/series/screenedtheater/