-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add contentTooLarge and tooManyrequestsError classes #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
faf2b25
feat: add contentTooLarge and tooManyrequestsError classes
almog8k 977bc6c
chore: remove gitHub actions old workflow for publishing package
almog8k d6a5d8c
chore: chore: update node.js version in workflow and .nvmrc to v20
almog8k fea0f4a
feat: update publish workflow to use custom init action and streamlin…
almog8k 9a56ceb
feat: add init-npm action to initialize repo and install dependencies
almog8k b485b5a
fix: pr issues
almog8k 88f47f4
chore: update nvmrc to v20
almog8k dcb4927
fix: eof
almog8k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,53 @@ | ||
| name: pull_request | ||
|
|
||
| on: [pull_request] | ||
| on: [pull_request, workflow_dispatch] | ||
|
|
||
| jobs: | ||
| tests: | ||
| name: Run Tests | ||
| eslint: | ||
| name: Run TS Project eslint | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node: [12.x, 14.x] | ||
| node: [20.x, 22.x] | ||
|
|
||
| steps: | ||
| - name: Check out Git repository | ||
| uses: actions/checkout@v2 | ||
| - name: Check out TS Project Git repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v1 | ||
| - name: Init nodejs | ||
| uses: ./.github/actions/init-npm | ||
| 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 | ||
| - name: Run TS Project linters | ||
| uses: wearerequired/lint-action@v2 | ||
| with: | ||
| name: Test Reporters | ||
| path: reports/** | ||
| github_token: ${{ secrets.github_token }} | ||
| # Enable linters | ||
| eslint: true | ||
| prettier: true | ||
| eslint_extensions: ts | ||
|
|
||
| eslint: | ||
| name: Run TS Project eslint | ||
| tests: | ||
| name: Run Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node: [20.x, 22.x] | ||
|
|
||
| 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 | ||
| with: | ||
| node-version: 12 | ||
| - name: Init nodejs | ||
| uses: ./.github/actions/init-npm | ||
|
|
||
| - name: Install TS Project dependencies | ||
| run: npm install | ||
| - name: Run tests | ||
| run: npm run test | ||
|
|
||
| - name: Run TS Project linters | ||
| uses: wearerequired/lint-action@v1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| github_token: ${{ secrets.github_token }} | ||
| # Enable linters | ||
| eslint: true | ||
| prettier: true | ||
| eslint_extensions: ts | ||
| name: Test Reporters ${{ matrix.node }} | ||
| path: ./reports/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v12 | ||
| v20 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import HttpStatus from 'http-status-codes'; | ||
| import { HttpError } from './httpError'; | ||
|
|
||
| export class ContentTooLarge extends HttpError { | ||
|
vitaligi marked this conversation as resolved.
|
||
| public constructor(message: string); | ||
| public constructor(error: Error, messageOverride?: string); | ||
| public constructor(error: string | Error, messageOverride?: string) { | ||
| if (error instanceof Error) { | ||
| super(error, HttpStatus.REQUEST_TOO_LONG, messageOverride); | ||
| } else { | ||
| super(error, HttpStatus.REQUEST_TOO_LONG); | ||
| } | ||
|
|
||
| // Issue: https://github.com/microsoft/TypeScript/issues/10166 | ||
| // Reference: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work | ||
| // Set the prototype explicitly. | ||
| Object.setPrototypeOf(this, ContentTooLarge.prototype); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import HttpStatus from 'http-status-codes'; | ||
| import { HttpError } from './httpError'; | ||
|
|
||
| export class TooManyRequestsError extends HttpError { | ||
|
vitaligi marked this conversation as resolved.
|
||
| public constructor(message: string); | ||
| public constructor(error: Error, messageOverride?: string); | ||
| public constructor(error: string | Error, messageOverride?: string) { | ||
| if (error instanceof Error) { | ||
| super(error, HttpStatus.TOO_MANY_REQUESTS, messageOverride); | ||
| } else { | ||
| super(error, HttpStatus.TOO_MANY_REQUESTS); | ||
| } | ||
|
|
||
| // Issue: https://github.com/microsoft/TypeScript/issues/10166 | ||
| // Reference: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work | ||
| // Set the prototype explicitly. | ||
| Object.setPrototypeOf(this, TooManyRequestsError.prototype); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.