1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-23 22:09:23 +00:00
comunicapiv2/src/controllers/MoviesController.ts

40 lines
771 B
TypeScript
Raw Normal View History

2020-01-03 07:39:59 +00:00
import { RequestHandler } from "../entities/RequestHandler";
import { MoviesHelper } from "../helpers/MoviesHelper";
import { Movie } from "../entities/Movies";
/**
* 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
*/
private 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
}
}
}