aboutsummaryrefslogtreecommitdiff
path: root/src/server/RouteSubscriber.ts
blob: e49be8af576c46d9934fc392c74d31fcabc5a979 (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
26
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;
    }

}