1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-23 13:59:22 +00:00
comunicapiv2/src/controllers/MoviesController.ts
2020-03-26 12:14:46 +01:00

40 lines
769 B
TypeScript

import { RequestHandler } from "../entities/RequestHandler";
import { MoviesHelper } from "../helpers/MoviesHelper";
import { Movie } from "../entities/Movie";
/**
* Movies controller
*
* @author Pierre HUBERT
*/
export class MoviesController {
/**
* Get the list of movies of the user
*
* @param h Request handler
*/
public static async GetList(h: RequestHandler) {
const list = await MoviesHelper.GetListUser(h.getUserId());
h.send(list.map((m) => this.MovieToAPI(m)));
}
/**
* Turn a movie into an API entry
*
* @param m The movie to convert
*/
public static MovieToAPI(m: Movie): any {
return {
id: m.id,
uri: m.uri,
url: m.url,
userID: m.userID,
name: m.name,
file_type: m.fileType,
size: m.size
}
}
}