Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit 351ee03

Browse files
authored
Remove external origin+path (#100)
1 parent 269b33f commit 351ee03

6 files changed

Lines changed: 38 additions & 41 deletions

File tree

README.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,25 @@ npm run test:integration
5252

5353
The following environment variables are used by `dcsp-api` and can be configured. Entries marked as `required` are needed when running `dscp-api` in production mode.
5454

55-
| variable | required | default | description |
56-
| :------------------------------ | :------: | :--------------------: | :---------------------------------------------------------------------------------------------------------------------------- |
57-
| PORT | N | `3001` | The port for the API to listen on |
58-
| EXTERNAL_ORIGIN | N | | The origin from which the OpenAPI service is accessible. If not provided the value will default to `http://localhost:${PORT}` |
59-
| EXTERNAL_PATH_PREFIX | N | | A path prefix from which this service is served |
60-
| API_HOST | Y | - | The hostname of the `dscp-node` the API should connect to |
61-
| API_PORT | N | `9944` | The port of the `dscp-node` the API should connect to |
62-
| LOG_LEVEL | N | `info` | Logging level. Valid values are [`trace`, `debug`, `info`, `warn`, `error`, `fatal`] |
63-
| USER_URI | Y | - | The Substrate `URI` representing the private key to use when making `dscp-node` transactions |
64-
| IPFS_HOST | Y | - | Hostname of the `IPFS` node to use for metadata storage |
65-
| IPFS_PORT | N | `15001` | Port of the `IPFS` node to use for metadata storage |
66-
| METADATA_KEY_LENGTH | N | `32` | Fixed length of metadata keys |
67-
| METADATA_VALUE_LITERAL_LENGTH | N | `32` | Fixed length of metadata LITERAL values |
68-
| API_VERSION | N | `package.json version` | API version |
69-
| API_MAJOR_VERSION | N | `v3` | API major version |
70-
| FILE_UPLOAD_MAX_SIZE | N | `200 * 1024 * 1024` | The Maximum file upload size (bytes) |
71-
| SUBSTRATE_STATUS_POLL_PERIOD_MS | N | `10 * 1000` | Number of ms between calls to check dscp-node status |
72-
| SUBSTRATE_STATUS_TIMEOUT_MS | N | `2 * 1000` | Number of ms to wait for response to dscp-node health requests |
73-
| IPFS_STATUS_POLL_PERIOD_MS | N | `10 * 1000` | Number of ms between calls to check ipfs status |
74-
| IPFS_STATUS_TIMEOUT_MS | N | `2 * 1000` | Number of ms to wait for response to ipfs health requests |
75-
| AUTH_TYPE | N | `NONE` | Authentication type for routes on the service. Valid values: [`NONE`, `JWT`, `EXTERNAL`] |
55+
| variable | required | default | description |
56+
| :------------------------------ | :------: | :--------------------: | :------------------------------------------------------------------------------------------- |
57+
| PORT | N | `3001` | The port for the API to listen on |
58+
| API_HOST | Y | - | The hostname of the `dscp-node` the API should connect to |
59+
| API_PORT | N | `9944` | The port of the `dscp-node` the API should connect to |
60+
| LOG_LEVEL | N | `info` | Logging level. Valid values are [`trace`, `debug`, `info`, `warn`, `error`, `fatal`] |
61+
| USER_URI | Y | - | The Substrate `URI` representing the private key to use when making `dscp-node` transactions |
62+
| IPFS_HOST | Y | - | Hostname of the `IPFS` node to use for metadata storage |
63+
| IPFS_PORT | N | `15001` | Port of the `IPFS` node to use for metadata storage |
64+
| METADATA_KEY_LENGTH | N | `32` | Fixed length of metadata keys |
65+
| METADATA_VALUE_LITERAL_LENGTH | N | `32` | Fixed length of metadata LITERAL values |
66+
| API_VERSION | N | `package.json version` | API version |
67+
| API_MAJOR_VERSION | N | `v3` | API major version |
68+
| FILE_UPLOAD_MAX_SIZE | N | `200 * 1024 * 1024` | The Maximum file upload size (bytes) |
69+
| SUBSTRATE_STATUS_POLL_PERIOD_MS | N | `10 * 1000` | Number of ms between calls to check dscp-node status |
70+
| SUBSTRATE_STATUS_TIMEOUT_MS | N | `2 * 1000` | Number of ms to wait for response to dscp-node health requests |
71+
| IPFS_STATUS_POLL_PERIOD_MS | N | `10 * 1000` | Number of ms between calls to check ipfs status |
72+
| IPFS_STATUS_TIMEOUT_MS | N | `2 * 1000` | Number of ms to wait for response to ipfs health requests |
73+
| AUTH_TYPE | N | `NONE` | Authentication type for routes on the service. Valid values: [`NONE`, `JWT`, `EXTERNAL`] |
7674

7775
The following environment variables are additionally used when `AUTH_TYPE : 'JWT'`
7876

@@ -153,7 +151,18 @@ The `inputs` field is an array of token `id`s that identifies the tokens to be c
153151
The `outputs` field is an array of objects that describe tokens to be created by running this process. To destroy tokens without creating any new ones simply pass an empty array. Each output must reference a `roles` object containing a (key, value) pair for each role associated with the new token. The value is the `AccountId` for the role. At minimum, a token requires the default `Owner` role to be set. The following role keys are accepted:
154152

155153
```json
156-
["Owner", "Customer", "AdditiveManufacturer", "Laboratory", "Buyer", "Supplier", "Reviewer", "Optimiser", "MemberA", "MemberB"]
154+
[
155+
"Owner",
156+
"Customer",
157+
"AdditiveManufacturer",
158+
"Laboratory",
159+
"Buyer",
160+
"Supplier",
161+
"Reviewer",
162+
"Optimiser",
163+
"MemberA",
164+
"MemberB"
165+
]
157166
```
158167

159168
Each output must also reference a `metadata` object containing a (key, value) pair for each metadata item associated with the new token. The following metadata value types are accepted:

app/api-v3/api-doc.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import env from '../env.js'
22

3-
const { PORT, API_VERSION, API_MAJOR_VERSION, EXTERNAL_ORIGIN, EXTERNAL_PATH_PREFIX } = env
4-
5-
let url = EXTERNAL_ORIGIN || `http://localhost:${PORT}`
6-
if (EXTERNAL_PATH_PREFIX) {
7-
url = `${url}/${EXTERNAL_PATH_PREFIX}`
8-
}
9-
url = `${url}/${API_MAJOR_VERSION}`
3+
const { PORT, API_VERSION, API_MAJOR_VERSION } = env
104

115
const apiDoc = {
126
openapi: '3.0.3',
@@ -16,7 +10,7 @@ const apiDoc = {
1610
},
1711
servers: [
1812
{
19-
url,
13+
url: `http://localhost:${PORT}/${API_MAJOR_VERSION}`,
2014
},
2115
],
2216
components: {

app/env.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ const vars = envalid.cleanEnv(process.env, {
4141
SUBSTRATE_STATUS_TIMEOUT_MS: envalid.num({ default: 2 * 1000 }),
4242
IPFS_STATUS_POLL_PERIOD_MS: envalid.num({ default: 10 * 1000 }),
4343
IPFS_STATUS_TIMEOUT_MS: envalid.num({ default: 2 * 1000 }),
44-
EXTERNAL_ORIGIN: envalid.str({ default: '' }),
45-
EXTERNAL_PATH_PREFIX: envalid.str({ default: '' }),
4644
})
4745

4846
export default {

app/server.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import url from 'url'
2222
const __filename = url.fileURLToPath(import.meta.url)
2323
const __dirname = path.dirname(__filename)
2424

25-
const { PORT, API_VERSION, API_MAJOR_VERSION, AUTH_TYPE, EXTERNAL_PATH_PREFIX } = env
25+
const { PORT, API_VERSION, API_MAJOR_VERSION, AUTH_TYPE } = env
2626

2727
export async function createHttpServer() {
2828
const requestLogger = pinoHttp({ logger })
@@ -116,11 +116,7 @@ export async function createHttpServer() {
116116
},
117117
}
118118

119-
app.use(
120-
EXTERNAL_PATH_PREFIX ? `/${EXTERNAL_PATH_PREFIX}/${API_MAJOR_VERSION}/swagger` : `/${API_MAJOR_VERSION}/swagger`,
121-
swaggerUi.serve,
122-
swaggerUi.setup(null, options)
123-
)
119+
app.use(`/${API_MAJOR_VERSION}/swagger`, swaggerUi.serve, swaggerUi.setup(null, options))
124120

125121
// Sorry - app.use checks arity
126122
// eslint-disable-next-line no-unused-vars

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dscp-api",
3-
"version": "5.0.7",
3+
"version": "5.0.8",
44
"description": "NodeJS API service for DSCP",
55
"type": "module",
66
"repository": {

0 commit comments

Comments
 (0)