mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-23 22:09:23 +00:00
40 lines
771 B
TypeScript
40 lines
771 B
TypeScript
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
|
|
}
|
|
}
|
|
} |