The Reference Data service provides a list of stock tickers and their associated company names via a RESTful interface.
This project assumes that your environment is already configured to use node and npm
By default this will run the application on localhost, port 18085, however the hostname and port can be modified by the following environment variables:
Environment Variable Name | Default Value |
---|---|
REFERENCE_DATA_SERVICE_PORT | 18085 |
HOSTNAME | localhost |
$ npm install
If you are developing the Reference Data service you can use the start:dev script instead. This runs with file watchers that will automatically rebuild and redeploy the application when the code changes:
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Assuming the Reference Data service is running from the default location, otherwise modify the hostname and/or port accordingly, then the following links are available:
- http://localhost:18085/api/ - the OpenAPI UI
- http://localhost:18085/stocks - the reference data
- http://localhost:18085/stocks/:ticker - the reference data for a specific ticker (or 404 if it does not exist)
The CSV of S&P 500 companies was populated by copying the data from this table from Wikipedia.
Obviously this is a lightweight nodeJS service, which you can run, but if you prefer, you can also run a mock of this service by installing @stoplight/prism-cli
This statically uses the example content in the OpenAPI spec to mock the service (you can specify --dynamic
to let it be more creative)
# Only need to do this once for your machine
sudo npm install -g @stoplight/prism-cli
Run prism to mock your OpenAPI spec as follows (Specify port
as you see fit).
ecurities is random on each request).
prism --cors --port 18085 mock openapi.yaml
You can then try out your requests against the mock service as follows: (or from a browser)
curl -X GET "http://localhost:18085/stocks" -H "accept: application/json"
curl -X GET "http://localhost:18085/stocks/ADBE" -H "accept: application/json"