engine.ts 2.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
 * Departamento de Informatica - Universidade Federal do Parana
 *
 * This file is part of blendb.
 *
 * blendb is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * blendb is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with blendb.  If not, see <http://www.gnu.org/licenses/>.
 */

import * as express from "express";
import { Request } from "../types";

24 25 26 27 28
/**
 * Constroller responsable for the static part from the API. In other
 * words, controller responsable for return the meta data stored in the
 * engine object that API users can use to create queries.
 */
29
export class EngineCtrl {
30 31 32 33 34 35 36
    /**
     * Route that returns the list of available metrics.
     * @param req - Object with request information
     * @param res - Object used to create and send the response
     * @param next - Call next middleware or controller. Not used but required
     * by typescript definition of route.
     */
37 38 39 40
    public static metrics(req: Request, res: express.Response, next: express.NextFunction) {
        res.status(200).json(req.engine.getMetricsDescription());
    }

41 42 43 44 45 46 47
    /**
     * Route that returns the list of available dimensions.
     * @param req - Object with request information
     * @param res - Object used to create and send the response
     * @param next - Call next middleware or controller. Not used but required
     * by typescript definition of route.
     */
48
    public static dimensions(req: Request, res: express.Response, next: express.NextFunction) {
49 50
        res.status(200).json(req.engine.getDimensionsDescription());
    }
51

52 53 54 55 56 57 58
    /**
     * Route that returns the list of available enumerable types.
     * @param req - Object with request information
     * @param res - Object used to create and send the response
     * @param next - Call next middleware or controller. Not used but required
     * by typescript definition of route.
     */
59 60 61
    public static enumTypes(req: Request, res: express.Response, next: express.NextFunction) {
        res.status(200).json(req.engine.getEnumTypesDescription());
    }
62

63 64 65 66 67 68 69
    /**
     * Route that returns the list of available data sources for insertion.
     * @param req - Object with request information
     * @param res - Object used to create and send the response
     * @param next - Call next middleware or controller. Not used but required
     * by typescript definition of route.
     */
70 71 72
    public static sources(req: Request, res: express.Response, next: express.NextFunction) {
       res.status(200).json(req.engine.getSourcesDescription());
    }
73
}