This is a REST API for handling Sprocket and Factory data.
git clone https://github.com/chrisg86/sprocket-factory-rest-api.git
npm install
Create an .env
file and set settings accordingly
cp .env.example .env
All relevant configuration can be found inside docker-compose.yml
. As I am using docker-compose, you need to make sure that the docker daemon is running before running this command.
docker-compose -f docker-compose.yml up
In case you want example data in the database, you can run import_data.sh
in the project root. This script relies on two files in the /data
folder, which will both be imported:
- seed_factory_data.sql
- seed_sprocket_types.sql
I generated those two seed files using this repository https://github.com/chrisg86/sprocket-factory-rest-api-tools
You might need to run tsc
once in order to build the entrypoint for node before running the dev command.
(once)
npx tsc
(when you have the build dir up and running)
npm run dev
By default the server will spin up on localhost with the PORT you provided in your .env
file (default 8000 https://localhost:8000)
By default the API will spin up on https://localhost:8000.
I've included PowerFlex.postman_collection.json
which you can import into Postman.
Complete openapi spec can be found in the openapi
root folder.
Note: I had conflicts between the spec definition and the online editor (https://editor-next.swagger.io/) for array types, so I included both versions in that folder
For running the unit tests, you can just use npm run test
For running integration tests, you need to spin up cypress using npm run cypress:open
.
Next choose the following on the page that starts up:
- E2E Testing
- Chrome and Start E2E Testing in Chrome
- Click the e2e test suite you want to run
Run code lint via npm run lint
Files get converted to javascript and stored in the build
root folder of the project.