@croudtech/crn-url-remapper

0.0.1 • Public • Published

CC-Node-Utils-CRN

Installation

Install the scoped package via the command line

via Yarn

yarn add @croudtech/cc-v3-base

via NPM

npm install @croudtech/cc-v3-base

Methods

These methods depend on valid SYSTEM_ID, INTERNAL_ROUTING_FORMAT and SERVICE_MAP variables being available in the environment.

publicUrlFromCrn

Builds a public url from a CRN string

Usage: publicUrlFromCrn(crnString)

CRN

croud-system-id:workflow-service:tasks:0c6b08f8-ed05-47ea-93a4-0f171fa9effb

URL

https://workflow-service.croudcontrol.com/tasks/0c6b08f8-ed05-47ea-93a4-0f171fa9effb

internalUrlFromCrn

Builds an internal kubernetes url from a CRN string (the path structure is definable in INTERNAL_ROUTING_FORMAT).

Usage: internalUrlFromCrn(crnString)

croud-system-id:workflow-service:tasks:0c6b08f8-ed05-47ea-93a4-0f171fa9effb

URL

http://workflow-service-django.v3-staging.svc.cluster.local/tasks/0c6b08f8-ed05-47ea-93a4-0f171fa9effb

createCrn

Creates a CRN using the SYSTEM_ID defined in the env and the following object structure.

Usage: createCrn(entityObject)

Object

[
    {
        entity: "files",
        id: 12345
    }
]

this will output a CRN ID:

croud-system-id:workflow-service:files:12345

multiple objects can be provided to specify nesting:

[
    {
        entity: "tasks",
        id: "0c6b08f8-ed05-47ea-93a4-0f171fa9effb"
    },
    {
        entity: "files",
        id: 12345
    }
]

croud-system-id:workflow-service:tasks:0c6b08f8-ed05-47ea-93a4-0f171fa9effb:files:12345

this of course, can in turn be converted to URLs using the methods described earlier.

appendEntity

This will add a systemId, entityId and public link to an entity. This method can take three arguments

  1. The entity itself. This must have an id property
  2. A string to describe the entity type. A future development will allow the entity to be a sequalize model and identify the model type automatically.
  3. An optional array of parent entity values. This is to allow for nesting entities in the CRN/link

Usage: appendEntity(entity, entityType, parentEntities)

Readme

Keywords

none

Package Sidebar

Install

npm i @croudtech/crn-url-remapper

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

8.51 kB

Total Files

4

Last publish

Collaborators

  • paul-watkins-croud
  • croud_admin
  • brockreece