Skip to the content.

OneBlink API CLI

Routes

Routes can be defined in two different ways to allow for ease of use or flexibility.

Directory Defined

Project Structure

The following directory structure:

|-- project-root
|   |-- .blinkmrc.json
|   |-- hellogalaxy
|   |   |-- index.js
|   |-- helloworld
|   |   |-- index.js
|   |-- lib
|   |   |-- common-code-one.js
|   |   |-- common-code-two.js

Would create the following routes:

  1. /hellogalaxy

  2. /helloworld

Notes

Configuration Defined

.blinkmrc.json

The following route definitions:

{
  "server": {
    "routes": [
      {
        "route": "/api/hello/{name}",
        "module": "./api/hello.js"
      },
      {
        "route": "/api/helloworld",
        "module": "./api/helloworld.js"
      }
    ]
  }
}

With the following directory structure:

|-- project-root
|   |-- .blinkmrc.json
|   |-- api
|   |   |-- hello.js
|   |   |-- helloworld.js
|   |-- lib
|   |   |-- common-code-one.js
|   |   |-- common-code-two.js

Would create the following routes:

  1. /api/hello/{name}

  2. /api/helloworld

Notes