aboutsummaryrefslogtreecommitdiff
path: root/src/server/RouteSubscriber.ts
blob: b923805a8db5bf28bf1742e8c8bb098427b521a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export default class RouteSubscriber {
    private _root: string;
    private requestParameters: string[] = [];

    constructor(root: string) {
        this._root = `/${root}`;
    }

    add(...parameters: string[]) {
        this.requestParameters.push(...parameters);
        return this;
    }

    public get root() {
        return this._root;
    }

    public get build() {
        let output = this._root;
        if (this.requestParameters.length) {
            output = `${output}/:${this.requestParameters.join('/:')}`;
        }
        return output;
    }
}