Skip to content
Snippets Groups Projects
personController.js 986 B
Newer Older
const db = require('../models/db');
Bastien's avatar
Bastien committed
const personServices = require('../services/person');
Bastien's avatar
Bastien committed
exports.getPersonInformations = async (req, res, next) => {
    let personId = req.params.id;

Bastien's avatar
Bastien committed
    try {
        let result = await personServices.getPersonById(personId);
        res.status(200).json(result);
    } catch (error) {
Bastien's avatar
Bastien committed
        res.status(500).json({ error : error.toString()});
Bastien's avatar
Bastien committed
    }
Bastien's avatar
Bastien committed
exports.getPersonMovies = async (req, res, next) => {
    let personId = req.params.id;

Bastien's avatar
Bastien committed
    try {
        let result = await personServices.getPersonMovies(personId);
        res.status(200).json(result);
    } catch (error) {
Bastien's avatar
Bastien committed
        res.status(500).json({ error : error.toString()});
Bastien's avatar
Bastien committed
    }
};

exports.searchPerson = async (req, res, next) => {
    let searchedName = req.query.name;

    try {
        let result = await personServices.searchPerson(searchedName);
        res.status(200).json(result);
    } catch (error) {
        res.status(500).json({ error : error.toString()});
    }