mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 12:12:55 +00:00
refactor: rename urlFragment in routes
This commit is contained in:
@@ -78,9 +78,9 @@ export interface SCRoute {
|
|||||||
statusCodeSuccess: number;
|
statusCodeSuccess: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL fragment of the route
|
* URL path of the route
|
||||||
*/
|
*/
|
||||||
urlFragment: string;
|
urlPath: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,16 +112,16 @@ export abstract class SCAbstractRoute implements SCRoute {
|
|||||||
*/
|
*/
|
||||||
statusCodeSuccess = 200;
|
statusCodeSuccess = 200;
|
||||||
/**
|
/**
|
||||||
* @see SCRoute.urlFragment
|
* @see SCRoute.urlPath
|
||||||
*/
|
*/
|
||||||
urlFragment = '/';
|
urlPath = '/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get "compiled" URL fragment
|
* Get "compiled" URL path
|
||||||
*
|
*
|
||||||
* @param parameters Parameters to compile URL fragment with
|
* @param parameters Parameters to compile URL path with
|
||||||
*/
|
*/
|
||||||
public getUrlFragment(parameters: SCMap<string> = {}): string {
|
public getUrlPath(parameters: SCMap<string> = {}): string {
|
||||||
let obligatoryParameters: string[] = [];
|
let obligatoryParameters: string[] = [];
|
||||||
|
|
||||||
if (typeof this.obligatoryParameters === 'object') {
|
if (typeof this.obligatoryParameters === 'object') {
|
||||||
@@ -132,7 +132,7 @@ export abstract class SCAbstractRoute implements SCRoute {
|
|||||||
throw new Error('Extraneous parameters provided.');
|
throw new Error('Extraneous parameters provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.urlFragment
|
return this.urlPath
|
||||||
.split('/')
|
.split('/')
|
||||||
.map((part) => {
|
.map((part) => {
|
||||||
if (part.indexOf(':') !== 0) {
|
if (part.indexOf(':') !== 0) {
|
||||||
|
|||||||
@@ -89,6 +89,6 @@ export class SCBookAvailabilityRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCBookAvailabilityRequest';
|
this.requestBodyName = 'SCBookAvailabilityRequest';
|
||||||
this.responseBodyName = 'SCBookAvailabilityResponse';
|
this.responseBodyName = 'SCBookAvailabilityResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/bookAvailability';
|
this.urlPath = '/bookAvailability';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,6 @@ export class SCBulkAddRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCBulkAddRequest';
|
this.requestBodyName = 'SCBulkAddRequest';
|
||||||
this.responseBodyName = 'SCBulkAddResponse';
|
this.responseBodyName = 'SCBulkAddResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.CREATED;
|
this.statusCodeSuccess = StatusCodes.CREATED;
|
||||||
this.urlFragment = '/bulk/:UID';
|
this.urlPath = '/bulk/:UID';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,6 @@ export class SCBulkDoneRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCBulkDoneRequest';
|
this.requestBodyName = 'SCBulkDoneRequest';
|
||||||
this.responseBodyName = 'SCBulkDoneResponse';
|
this.responseBodyName = 'SCBulkDoneResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.NO_CONTENT;
|
this.statusCodeSuccess = StatusCodes.NO_CONTENT;
|
||||||
this.urlFragment = '/bulk/:UID/done';
|
this.urlPath = '/bulk/:UID/done';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,6 @@ export class SCBulkRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCBulkRequest';
|
this.requestBodyName = 'SCBulkRequest';
|
||||||
this.responseBodyName = 'SCBulkResponse';
|
this.responseBodyName = 'SCBulkResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/bulk';
|
this.urlPath = '/bulk';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export class SCFeedbackRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCFeedbackRequest';
|
this.requestBodyName = 'SCFeedbackRequest';
|
||||||
this.responseBodyName = 'SCFeedbackResponse';
|
this.responseBodyName = 'SCFeedbackResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/feedback';
|
this.urlPath = '/feedback';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,6 @@ export class SCIndexRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCIndexRequest';
|
this.requestBodyName = 'SCIndexRequest';
|
||||||
this.responseBodyName = 'SCIndexResponse';
|
this.responseBodyName = 'SCIndexResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/';
|
this.urlPath = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,6 @@ export class SCPluginRegisterRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCPluginRegisterRequest';
|
this.requestBodyName = 'SCPluginRegisterRequest';
|
||||||
this.responseBodyName = 'SCPluginRegisterResponse';
|
this.responseBodyName = 'SCPluginRegisterResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/plugin/register';
|
this.urlPath = '/plugin/register';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,6 @@ export class SCMultiSearchRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCMultiSearchRequest';
|
this.requestBodyName = 'SCMultiSearchRequest';
|
||||||
this.responseBodyName = 'SCMultiSearchResponse';
|
this.responseBodyName = 'SCMultiSearchResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/search/multi';
|
this.urlPath = '/search/multi';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,6 @@ export class SCSearchRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCSearchRequest';
|
this.requestBodyName = 'SCSearchRequest';
|
||||||
this.responseBodyName = 'SCSearchResponse';
|
this.responseBodyName = 'SCSearchResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/search';
|
this.urlPath = '/search';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,6 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
|
|||||||
this.requestBodyName = 'SCThingUpdateRequest';
|
this.requestBodyName = 'SCThingUpdateRequest';
|
||||||
this.responseBodyName = 'SCThingUpdateResponse';
|
this.responseBodyName = 'SCThingUpdateResponse';
|
||||||
this.statusCodeSuccess = StatusCodes.OK;
|
this.statusCodeSuccess = StatusCodes.OK;
|
||||||
this.urlFragment = '/:TYPE/:UID';
|
this.urlPath = '/:TYPE/:UID';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,26 +21,26 @@ import {SCThingUpdateRoute} from '../src/protocol/routes/thing-update';
|
|||||||
@suite(timeout(10000), slow(5000))
|
@suite(timeout(10000), slow(5000))
|
||||||
export class RoutesSpec {
|
export class RoutesSpec {
|
||||||
@test
|
@test
|
||||||
public bulkAddRouteUrlFragment() {
|
public bulkAddRouteUrlPath() {
|
||||||
const bulkAddRoute = new SCBulkAddRoute();
|
const bulkAddRoute = new SCBulkAddRoute();
|
||||||
|
|
||||||
expect(bulkAddRoute.getUrlFragment({
|
expect(bulkAddRoute.getUrlPath({
|
||||||
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
||||||
})).to.equal('/bulk/540862f3-ea30-5b8f-8678-56b4dc217140');
|
})).to.equal('/bulk/540862f3-ea30-5b8f-8678-56b4dc217140');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public bulkRouteUrlFragment() {
|
public bulkRouteUrlPath() {
|
||||||
const bulkRoute = new SCBulkRoute();
|
const bulkRoute = new SCBulkRoute();
|
||||||
|
|
||||||
expect(bulkRoute.getUrlFragment()).to.equal('/bulk');
|
expect(bulkRoute.getUrlPath()).to.equal('/bulk');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public thingUpdateRouteUrlFragment() {
|
public thingUpdateRouteUrlPath() {
|
||||||
const thingUpdateRoute = new SCThingUpdateRoute();
|
const thingUpdateRoute = new SCThingUpdateRoute();
|
||||||
|
|
||||||
expect(thingUpdateRoute.getUrlFragment({
|
expect(thingUpdateRoute.getUrlPath({
|
||||||
TYPE: 'dish',
|
TYPE: 'dish',
|
||||||
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
||||||
})).to.equal('/dish/540862f3-ea30-5b8f-8678-56b4dc217140');
|
})).to.equal('/dish/540862f3-ea30-5b8f-8678-56b4dc217140');
|
||||||
@@ -51,7 +51,7 @@ export class RoutesSpec {
|
|||||||
const thingUpdateRoute = new SCThingUpdateRoute();
|
const thingUpdateRoute = new SCThingUpdateRoute();
|
||||||
|
|
||||||
const fn = () => {
|
const fn = () => {
|
||||||
thingUpdateRoute.getUrlFragment({
|
thingUpdateRoute.getUrlPath({
|
||||||
FOO: 'bar',
|
FOO: 'bar',
|
||||||
TYPE: 'dish',
|
TYPE: 'dish',
|
||||||
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
||||||
@@ -66,7 +66,7 @@ export class RoutesSpec {
|
|||||||
const thingUpdateRoute = new SCThingUpdateRoute();
|
const thingUpdateRoute = new SCThingUpdateRoute();
|
||||||
|
|
||||||
const fn = () => {
|
const fn = () => {
|
||||||
thingUpdateRoute.getUrlFragment({
|
thingUpdateRoute.getUrlPath({
|
||||||
TYPO: 'dish',
|
TYPO: 'dish',
|
||||||
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user