Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/init-npm/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: init-npm
description: 'Initialize the repo with npm and install all the dependencies'
inputs:
node-version:
description: 'Node.js version'
required: true
default: '20.x'
runs:
using: composite
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: npm
- name: Install TS Project dependencies
shell: bash
run: npm ci
- name: build
shell: bash
run: npm run build
12 changes: 6 additions & 6 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: publish

on:
workflow_dispatch:
release:
types: [published]
branches: [master]


jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -12,11 +13,10 @@ jobs:
packages: write # allow GITHUB_TOKEN to publish packages
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Init nodejs
uses: ./.github/actions/init-npm
with:
node-version: "20"
- run: npm ci
- run: npm run prepack
node-version: 20.x
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
run: |
git config --global user.email "mapcolonies@gmail.com"
git config --global user.name "mapcolonies"

- name: Bump new version
run: npm run release

Expand Down
28 changes: 8 additions & 20 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
name: pull_request

on: [pull_request]

jobs:
tests:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.x, 18.x]

node: [16.x, 18.x, 20.x, 22.x]
steps:
- name: Check out Git repository
uses: actions/checkout@v2

uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Install Node.js dependencies
run: npm ci

- name: Run tests
run: npm run test

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: Test Reporters
name: Test Reporters-${{ matrix.node }}
path: reports/**

eslint:
name: Run TS Project eslint
runs-on: ubuntu-latest

steps:
- name: Check out TS Project Git repository
uses: actions/checkout@v2

uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install TS Project dependencies
run: npm install

- name: Run TS Project linters
uses: wearerequired/lint-action@v1
uses: wearerequired/lint-action@v2
with:
github_token: ${{ secrets.github_token }}
# Enable linters
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"ngeohash": "^0.6.3"
},
"peerDependencies": {
"@map-colonies/error-types": "^1.2.0",
"@map-colonies/error-types": "^1.3.1",
"@map-colonies/js-logger": "^1.0.1"
}
}
46 changes: 36 additions & 10 deletions src/communication/http/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
UnauthorizedError,
HttpError,
MethodNotAllowedError,
ContentTooLarge,
TooManyRequestsError,
} from '@map-colonies/error-types';
import { Logger } from '@map-colonies/js-logger';

Expand Down Expand Up @@ -266,7 +268,7 @@ export abstract class HttpClient {
url,
body,
targetService: this.targetService,
msg: `invalid request error recieved from service ${this.targetService}.`,
msg: `invalid request error received from service ${this.targetService}.`,
msgError: err.message,
});
}
Expand All @@ -278,7 +280,7 @@ export abstract class HttpClient {
url,
body,
targetService: this.targetService,
msg: `not found error recieved from service ${this.targetService}.`,
msg: `not found error received from service ${this.targetService}.`,
msgError: err.message,
});
}
Expand All @@ -290,7 +292,7 @@ export abstract class HttpClient {
url,
body,
targetService: this.targetService,
msg: `conflict error recieved from service ${this.targetService}.`,
msg: `conflict error received from service ${this.targetService}.`,
msgError: err.message,
});
}
Expand All @@ -302,42 +304,66 @@ export abstract class HttpClient {
url,
body,
targetService: this.targetService,
msg: `forbidden error recieved from service ${this.targetService}.`,
msg: `forbidden error received from service ${this.targetService}.`,
msgError: err.message,
});
}
throw new ForbiddenError(err, message);
return new ForbiddenError(err, message);
case HttpStatus.UNAUTHORIZED:
if (!this.disableDebugLogs) {
this.logger.debug({
err,
url,
body,
targetService: this.targetService,
msg: `unauthorized error recieved from service ${this.targetService}.`,
msg: `unauthorized error received from service ${this.targetService}.`,
msgError: err.message,
});
}
throw new UnauthorizedError(err, message);
return new UnauthorizedError(err, message);
case HttpStatus.METHOD_NOT_ALLOWED:
if (!this.disableDebugLogs) {
this.logger.debug({
err,
url,
body,
targetService: this.targetService,
msg: `method not allowed error recieved from service ${this.targetService}.`,
msg: `method not allowed error received from service ${this.targetService}.`,
msgError: err.message,
});
}
throw new MethodNotAllowedError(err, message);
return new MethodNotAllowedError(err, message);
case HttpStatus.REQUEST_TOO_LONG:
if (!this.disableDebugLogs) {
this.logger.debug({
err,
url,
body,
targetService: this.targetService,
msg: `content too large error received from service ${this.targetService}.`,
msgError: err.message,
});
}
return new ContentTooLarge(err, message);
case HttpStatus.TOO_MANY_REQUESTS:
if (!this.disableDebugLogs) {
this.logger.debug({
err,
url,
body,
targetService: this.targetService,
msg: `too many requests error received from service ${this.targetService}.`,
msgError: err.message,
});
}
return new TooManyRequestsError(err, message);
default:
this.logger.error({
err,
url,
body,
targetService: this.targetService,
msg: `Internal Server Error recieved from service ${this.targetService}.`,
msg: `Internal Server Error received from service ${this.targetService}.`,
msgError: err.message,
});
return new InternalServerError(err);
Expand Down
Loading