-
Notifications
You must be signed in to change notification settings - Fork 6
Configurable proxy and local sensorthings API #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Alberto!
LGTM, but we need to fix the small thing about the credentials header.
src/config.js
Outdated
|
||
const remoteSTConfig = { | ||
server: { | ||
doc: 'SensorThings sandbox API server', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if we use something different to SensorUp, this might not be a sandbox anymore :)
src/config.js
Outdated
default: 'https://pg-api.sensorup.com' | ||
}, | ||
path: { | ||
doc: 'SensorThings sandbox API path', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
src/config.js
Outdated
}, | ||
credentials: { | ||
token: { | ||
doc: 'SensorThings sandbox API credentials', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
src/routes/sensorthings.js
Outdated
* You will need to get an access token by creating an account at | ||
* https://pg.sensorup.com/playground.html | ||
* | ||
* Add the access token to your 'sandboxToken' config file entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe reword this comment to explain that we use SensorUp's for now, but this code is ready to proxy to other ST external services. Also, a comment at the top of the file explaining the local vs remote choices might be helpful.
src/routes/sensorthings.js
Outdated
}, | ||
decorateRequest: (proxyReq, originalReq) => { | ||
// Add SensorUp auth header. | ||
proxyReq.headers['St-P-Access-Token'] = config.get('sensorthings.remote.credentials.token'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header is specific to SensorUp. Maybe we need to add a config option for this. Let's keep it simple for now and assume that an external ST service only takes its credentials through a header:
credentials: {
header: 'St-P-Access-Token',
value: 'token'
}
57287b3
to
4dc5d98
Compare
Looks good! It seems that you need to tweak the tests config file though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the tests green again and feel free to merge. Thanks!
No description provided.