Below are several ways to get the API serving content. After getting an API running, you will need to replace the service.endpoint
config parameter in the browser config with the url that will allow access to it. For example, if you are running the server locally on port 2000 while developing, you can change the service URL to http://localhost:2000
.
Run via CLI
You can install the cli server globally.
npm install -g @shotput/api
or locally
npm install @shotput/api
If you installed it globally, you can simply start up the server with
shotput-server --port {port} --configFile {config file}
While locally, you will need to use the node_modules directory
node node_modules/@shotputter/api/dist/shotput-server.js --port {port} --configFile {config file}
The options for running the cli are
port
integer What port to run onconfigFile
file reference Which config file to use when running to API server.
Docker
Shotputter provides docker image to Docker hub to run the api server. The docker container is a wrapper for the cli and can be configured the same with - with a file or environment variables.
An example for running the docker container if there is a “config.json” in the current working directory.
docker run -d -p 3000:3000 --mount type=bind,source="$(pwd)",target=/opt/app/configuration adamsar/shotputter --configFile /opt/app/configuration/config.json
AWS Serverless
Shotputter is bundled with a serverless file to help bootstrap an AWS Lambda and AWS S3 centered deployment. This file is available in the node_modules/@shotputter/api/serverless-example.yml
folder if installing locally, or on Github
To run this file, you will need to set the appropriate configuration environment variables, and make sure you point the functions handlers to node_modules/dist/lambda.handler
.
To use s3 to host the images that Shotput will write, edit the iamRoleStatements section of the serverless file and replace S3_BUCKET with the bucket you would like to write to (ensure this bucket has public read permissions).
Alternatively you can provide your own iamRole in the serverless file that can access S3.