{"size": 933, "ext": "js", "max_stars_repo_path": "dist/es2017/index.js", "max_stars_repo_name": "dragoscirjan/controller", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dist/es2017/index.js", "max_issues_repo_name": "dragoscirjan/controller", "max_issues_repo_issues_event_min_datetime": "2020-03-14T15:27:40.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-08T13:12:17.000Z", "max_forks_repo_path": "dist/es2017/index.js", "max_forks_repo_name": "glasswingjs/controller", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 26.6571428571, "max_line_length": 97, "alphanum_fraction": 0.6237942122}
import 'reflect-metadata';
import { ROUTE_REGISTRY_METADATA_NAME, RouteRegistry } from '@glasswing/router';
import { singleton } from 'tsyringe';

/**
 * Abstract Controller class.
 */
class AbstractController {
    constructor() {
        if (!Reflect.hasMetadata(ROUTE_REGISTRY_METADATA_NAME, this)) {
            Reflect.defineMetadata(ROUTE_REGISTRY_METADATA_NAME, new RouteRegistry(), this);
        }
    }
}

/**
 * Comment
 *
 * @returns {ClassDecorator}
 */
const Controller = () => (target) => {
    const extended = class extends target {
        constructor(...args) {
            super(...args);
            if (!Reflect.hasMetadata(ROUTE_REGISTRY_METADATA_NAME, this)) {
                Reflect.defineMetadata(ROUTE_REGISTRY_METADATA_NAME, new RouteRegistry(), this);
            }
        }
    };
    singleton()(extended);
    return extended;
};

export { AbstractController, Controller };
