diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f12ed04d..740bfa6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,6 +47,7 @@ jobs: working-directory: discord-bot - run: npm test working-directory: discord-bot + test-ecommerce: runs-on: ${{ matrix.os }} strategy: @@ -87,4 +88,46 @@ jobs: - run: npm run lint working-directory: netlify-functions-ecommerce - run: npm test - working-directory: netlify-functions-ecommerce \ No newline at end of file + working-directory: netlify-functions-ecommerce + + test-reviews: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + node: [16] + os: [ubuntu-20.04] + name: Reviews Sample App + steps: + ## Set up Stargate + - name: disable and stop mono-xsp4.service + run: | + sudo kill -9 $(sudo lsof -t -i:8084) + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + repository: stargate/stargate-mongoose + path: stargate-mongoose + ref: main + - name: Set up JSON API + run: | + chmod +x bin/start_json_api.sh + bin/start_json_api.sh + working-directory: stargate-mongoose + - name: Wait for services + run: | + while ! nc -z localhost 8181; do sleep 1; done + while ! nc -z localhost 8081; do sleep 1; done + working-directory: stargate-mongoose + ## Set up and run reviews sample app tests + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 + - name: Setup node + uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.1.1 + with: + node-version: ${{ matrix.node }} + + - run: npm install + working-directory: typescript-express-reviews + - run: npm run build + working-directory: typescript-express-reviews + - run: npm test + working-directory: typescript-express-reviews \ No newline at end of file diff --git a/typescript-express-reviews/.env b/typescript-express-reviews/.env deleted file mode 100644 index b67ed8ac..00000000 --- a/typescript-express-reviews/.env +++ /dev/null @@ -1,4 +0,0 @@ -STARGATE_JSON_API_URL=http://127.0.0.1:8181/v1/reviews -STARGATE_JSON_USERNAME=cassandra -STARGATE_JSON_PASSWORD=cassandra -STARGATE_JSON_AUTH_URL=http://localhost:8081/v1/auth \ No newline at end of file diff --git a/typescript-express-reviews/.env.example b/typescript-express-reviews/.env.example new file mode 100644 index 00000000..1dae1bbe --- /dev/null +++ b/typescript-express-reviews/.env.example @@ -0,0 +1,23 @@ +# Flag to specify whether the remote endpoint is Astra or not. +# true - if connecting to an AstraDB +# false - if not connecting to an AstraDB and connecting to a local/remote jsonapi instead +IS_ASTRA= + +#Fill the JSON API related details only when IS_ASTRA is set to 'false' +#Local JSON API URL for example: http://127.0.0.1:8181/v1/ecommerce_test where 'ecommerce_test' is the keyspace name +JSON_API_URL=http://127.0.0.1:8181/v1/ecommerce_test +#Auth URL for example: http://127.0.0.1:8081/v1/auth +JSON_API_AUTH_URL=http://127.0.0.1:8081/v1/auth +#Auth username and password +JSON_API_AUTH_USERNAME=cassandra +JSON_API_AUTH_PASSWORD=cassandra + +#Fill the ASTRA DB related details only when IS_ASTRA is set to 'true' +#Astra DB Id +ASTRA_DBID= +#Astra DB Region +ASTRA_REGION= +#Astra DB Keyspace +ASTRA_KEYSPACE= +#Astra DB Application Token +ASTRA_APPLICATION_TOKEN= \ No newline at end of file diff --git a/typescript-express-reviews/.gitignore b/typescript-express-reviews/.gitignore new file mode 100644 index 00000000..4c49bd78 --- /dev/null +++ b/typescript-express-reviews/.gitignore @@ -0,0 +1 @@ +.env diff --git a/typescript-express-reviews/README.md b/typescript-express-reviews/README.md index 88cd487f..f19b44fe 100644 --- a/typescript-express-reviews/README.md +++ b/typescript-express-reviews/README.md @@ -9,6 +9,7 @@ Make sure you have Node.js 14 or higher and a local Stargate instance running as ## Running This Example 1. Run `npm install` +1. Create a `.env` file using the instructions in `.env.example` 1. Run `npm run seed` 1. Run `npm run build` to build the example 1. Run `npm start` diff --git a/typescript-express-reviews/src/api/Review/findByVehicle.ts b/typescript-express-reviews/src/api/Review/findByVehicle.ts index 4b991d30..a569b910 100644 --- a/typescript-express-reviews/src/api/Review/findByVehicle.ts +++ b/typescript-express-reviews/src/api/Review/findByVehicle.ts @@ -6,10 +6,11 @@ async function findByVehicle (request: Request, response: Response): Promise