Skip to content
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

feat!: implement with unjs template #9

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.js]
indent_style = space
indent_size = 2

[{package.json,*.yml,*.cjson}]
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
dist
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["eslint-config-unjs"],
"rules": {}
}
26 changes: 26 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: ["main"]

permissions:
contents: read

jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- name: Fix lint issues
run: pnpm run lint:fix
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9
with:
commit-message: "chore: apply automated fixes"
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ci

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- run: pnpm lint
- run: pnpm test:types
- run: pnpm build
- run: pnpm vitest --coverage
- uses: codecov/codecov-action@v3
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
.vscode
node_modules
*.log*
coverage
dist
types
.vscode
.DS_Store
.eslintcache
*.log*
*.conf*
*.env*
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
49 changes: 0 additions & 49 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Pooya Parsa
Copyright (c)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
55 changes: 42 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# is-https
> Check if the given request is HTTPS

[![npm](https://img.shields.io/npm/dt/is-https.svg?style=flat-square)](https://npmjs.com/package/is-https)
[![npm (scoped with tag)](https://img.shields.io/npm/v/is-https/latest.svg?style=flat-square)](https://npmjs.com/package/is-https)
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions][github-actions-src]][github-actions-href]
[![Codecov][codecov-src]][codecov-href]

> Check if the given request is HTTPS

## Usage

Install package:

```bash
yarn add is-https
# or
```sh
# npm
npm install is-https

# yarn
yarn add is-https

# pnpm
pnpm install is-https
```

Import:

```js
const isHTTPS = require('is-https')
// or
import isHTTPS from 'is-https'
```
// ESM
import { isHTTPS } from "unjs/is-https"

```ts
function isHTTPS(req: IncomingMessage, trustProxy: Boolean = true): Boolean | undefined
// CommonJS
const { isHTTPS } = require("unjs/is-https")
```

## Behaviour
Expand All @@ -40,6 +48,27 @@ Returns either `true` or `false` based on checks or `undefined` if no check was

- [redirect-ssl](https://www.npmjs.com/package/redirect-ssl) - Connect middleware to enforce HTTPS

## Development

- Clone this repository
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`

## License

MIT
Made with 💛

Published under [MIT License](./LICENSE).

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/is-https?style=flat-square
[npm-version-href]: https://npmjs.com/package/is-https
[npm-downloads-src]: https://img.shields.io/npm/dm/is-https?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/is-https
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/is-https/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/is-https/actions?query=workflow%3Aci
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/is-https/main?style=flat-square
[codecov-href]: https://codecov.io/gh/unjs/is-https
34 changes: 25 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,44 @@
"name": "is-https",
"version": "4.0.0",
"description": "Check if the given request is HTTPS",
"author": "Pooya Parsa <[email protected]>",
"repository": "unjs/is-https",
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "siroc build",
"release": "yarn build && standard-version && npm publish && git push --follow-tags"
"build": "unbuild",
"dev": "vitest dev",
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src test",
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src test -w",
"prepack": "pnpm run build",
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
"test:types": "tsc --noEmit --skipLibCheck"
},
"devDependencies": {
"@types/node": "latest",
"siroc": "latest",
"standard-version": "latest"
}
"@types/node": "^20.5.4",
"@vitest/coverage-v8": "^0.34.2",
"changelogen": "^0.5.5",
"eslint": "^8.47.0",
"eslint-config-unjs": "^0.2.1",
"prettier": "^3.0.2",
"typescript": "^5.1.6",
"unbuild": "^2.0.0",
"vitest": "^0.34.2"
},
"packageManager": "[email protected]"
}
Loading