/*!
 * @copyright FLYACTS GmbH <%= now.format('YYYY') %>
 */

import {
    Authorized,
    Get,
    JsonController,
} from '@flyacts/routing-controllers';
import { Service } from 'typedi';
import { Connection } from 'typeorm';

import { <%= classify(name) %>Entity } from '../entities/<%= dasherize(name) %>.entity';

/**
 * Controller for /<%= dasherize(pluralize(name)) %>
 */
@JsonController('/<%= dasherize(pluralize(name)) %>')
@Service()
export class <%= classify(name) %>Controller {

    public constructor(
        private connection: Connection,
    ) { }

    /**
     *  Get all <%= classify(pluralize(name)) %>
     */
    @Get()
    @Authorized()
    public async findAll<%= classify(pluralize(name)) %>() {
        return this
            .connection
            .manager
            .find(
                <%= classify(name) %>Entity,
                {
                    order: {
                        name: 'ASC',
                    },
                },
            );
    }
}
