From d6c16d7d5e79f29bd0d60395eebf3165d0ca5366 Mon Sep 17 00:00:00 2001 From: leosantosw Date: Thu, 25 Jan 2024 13:25:12 -0300 Subject: [PATCH] add havesine distance lib --- .github/workflows/cd.yml | 42 ++++++++++++++++++++++++++++++++++++++++ package-lock.json | 8 +++++++- package.json | 7 ++++--- serverless.yml | 1 + 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..1e5bca9 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,42 @@ +name: CD + +on: + push: + branches: + - main + - develop + +jobs: + cd: + name: CD + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Serverless credentials + run: | + mkdir ~/.aws && echo "${{ secrets.AWS_LAMBDA_PROFILES }}" > ~/.aws/credentials + - name: Install Dependencies + run: npm i + + # Deploy in staging + - name: Deploy staging + if: github.ref == 'refs/heads/develop' + # [TODO] + + # Deploy in production + - name: Deploy production + if: github.ref == 'refs/heads/main' + # [TODO] + diff --git a/package-lock.json b/package-lock.json index 0c4e540..2212c59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,8 @@ "name": "customer-api", "version": "1.0.0", "dependencies": { - "pg": "^8.11.3" + "haversine-distance": "^1.2.1", + "pg": "8.11.3" }, "devDependencies": { "eslint": "8.32.0", @@ -5497,6 +5498,11 @@ "node": ">= 0.4" } }, + "node_modules/haversine-distance": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/haversine-distance/-/haversine-distance-1.2.1.tgz", + "integrity": "sha512-rQpG89d6NlAis0eqOSFXDqNU/GZcMPlHNVMqTSzD16niD9s1fDK8T6kwrK0WJ7OMU+iRNy3cgGYnNQihMqmaHg==" + }, "node_modules/hexoid": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", diff --git a/package.json b/package.json index 74f8ead..066cac0 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,10 @@ "dev": "./scripts/start-local.sh", "lint": "eslint ." }, + "dependencies": { + "pg": "8.11.3", + "haversine-distance": "1.2.1" + }, "devDependencies": { "eslint": "8.32.0", "eslint-config-standard": "17.0.0", @@ -14,8 +18,5 @@ "eslint-plugin-promise": "6.1.1", "serverless-offline": "12.0.4", "serverless-prune-plugin": "2.0.1" - }, - "dependencies": { - "pg": "8.11.3" } } diff --git a/serverless.yml b/serverless.yml index 67c1729..91e4dd2 100644 --- a/serverless.yml +++ b/serverless.yml @@ -33,6 +33,7 @@ custom: functions: - ${file(./infra/lambda/list-customers.yml)} - ${file(./infra/lambda/create-customer.yml)} + - ${file(./infra/lambda/nearby-customers.yml)} resources: - ${file(./infra/api-gateway/auth-response.yml)}