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
14 changes: 8 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,12 @@ 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
- name: Copy resources
run: npm run copy
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
56 changes: 0 additions & 56 deletions .github/workflows/publish_package.yml

This file was deleted.

63 changes: 30 additions & 33 deletions .github/workflows/pull_request.yml
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/**
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12
v20
Comment thread
vitaligi marked this conversation as resolved.
19 changes: 19 additions & 0 deletions src/http/contentTooLargeError.ts
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 {
Comment thread
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);
}
}
2 changes: 2 additions & 0 deletions src/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export * from './noContentError';
export * from './unprocessableEntity';
export * from './insufficientStorage';
export * from './methodNotAllowedError';
export * from './tooManyRequestsError';
export * from './contentTooLargeError';
19 changes: 19 additions & 0 deletions src/http/tooManyRequestsError.ts
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 {
Comment thread
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);
}
}