Skip to content

Commit

Permalink
eslint, chubbyts-function-mock, node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed May 14, 2023
1 parent bb87237 commit e808afc
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 212 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@chubbyts/chubbyts-eslint/dist/eslintrc').default;
29 changes: 6 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,15 @@ name: CI
on:
push:
pull_request:
branches:
- master
schedule:
- cron: '0 0 * * *'

jobs:
node14:
name: Node 14
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v3
- name: checkout node
uses: actions/setup-node@v3
with:
node-version: '14'
- run: npm install
- run: npm run cs
- run: npm test -- --coverage --no-cache
- run: npm run infection
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
node16:
name: Node 16
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -34,14 +20,10 @@ jobs:
with:
node-version: '16'
- run: npm install
- run: npm run cs
- run: npm test -- --coverage --no-cache
- run: npm run infection
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
- run: npm test
node18:
name: Node 18
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -50,6 +32,7 @@ jobs:
with:
node-version: '18'
- run: npm install
- run: npm run lint
- run: npm run cs
- run: npm test -- --coverage --no-cache
- run: npm run infection
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ A CORS middleware for @chubbyts/chubbyts-http-types.

## Requirements

* node: 14
* node: 16
* [@chubbyts/chubbyts-http-types][2]: ^1.1.0

## Installation

Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-cors][1].

```ts
npm i @chubbyts/chubbyts-cors@^1.0.4
npm i @chubbyts/chubbyts-cors@^1.1.0
```

## Usage
Expand Down Expand Up @@ -65,3 +66,4 @@ const corsMiddleware = createCorsMiddleware(
2023 Dominik Zogg

[1]: https://www.npmjs.com/package/@chubbyts/chubbyts-cors
[2]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-types
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chubbyts/chubbyts-cors",
"version": "1.0.4",
"version": "1.1.0",
"description": "A CORS middleware for @chubbyts/chubbyts-http-types.",
"keywords": [],
"author": "Dominik Zogg",
Expand All @@ -9,6 +9,8 @@
"scripts": {
"cs-fix": "prettier --write src tests",
"cs": "prettier --check src tests",
"lint-fix": "eslint src tests --fix",
"lint": "eslint src tests",
"test": "jest",
"infection": "stryker run",
"build": "rm -Rf dist && tsc",
Expand Down Expand Up @@ -36,20 +38,22 @@
"dist"
],
"engines": {
"node": ">=14"
"node": ">=16"
},
"dependencies": {
"@chubbyts/chubbyts-http-types": "^1.0.0"
"@chubbyts/chubbyts-http-types": "^1.1.0"
},
"devDependencies": {
"@stryker-mutator/core": "^6.4.1",
"@stryker-mutator/jest-runner": "^6.4.1",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.3",
"@chubbyts/chubbyts-eslint": "^1.1.1",
"@chubbyts/chubbyts-function-mock": "^1.3.3",
"@stryker-mutator/core": "^6.4.2",
"@stryker-mutator/jest-runner": "^6.4.2",
"@types/jest": "^29.5.1",
"@types/node": "^20.1.4",
"jest": "^29.5.0",
"prettier": "^2.8.4",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
"prettier": "^2.8.8",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
},
"publishConfig": {
"access": "public"
Expand Down
15 changes: 8 additions & 7 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Handler } from '@chubbyts/chubbyts-http-types/dist/handler';
import { Method, Response, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message';
import { Middleware } from '@chubbyts/chubbyts-http-types/dist/middleware';
import { ResponseFactory } from '@chubbyts/chubbyts-http-types/dist/message-factory';
import { HeadersNegotiator, MethodNegotiator, OriginNegotiator } from './negotiation';
import type { Handler } from '@chubbyts/chubbyts-http-types/dist/handler';
import type { Response, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message';
import { Method } from '@chubbyts/chubbyts-http-types/dist/message';
import type { Middleware } from '@chubbyts/chubbyts-http-types/dist/middleware';
import type { ResponseFactory } from '@chubbyts/chubbyts-http-types/dist/message-factory';
import type { HeadersNegotiator, MethodNegotiator, OriginNegotiator } from './negotiation';

const isPreflight = (request: ServerRequest) => request.method.toUpperCase() === Method.OPTIONS;

Expand Down Expand Up @@ -114,8 +115,8 @@ export const createCorsMiddleware = (
methodNegotiator: MethodNegotiator,
headersNegotiator: HeadersNegotiator,
exposeHeaders: Array<string> = [],
allowCredentials: boolean = false,
maxAge: number = 600,
allowCredentials = false,
maxAge = 600,
): Middleware => {
return async (request: ServerRequest, handler: Handler): Promise<Response> => {
if (isPreflight(request)) {
Expand Down
2 changes: 1 addition & 1 deletion src/negotiation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Method, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message';
import type { Method, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message';

export type AllowOrigin = (origin: string) => boolean;

Expand Down
Loading

0 comments on commit e808afc

Please sign in to comment.