Comparing version 0.0.8-beta to 0.0.9
{ | ||
"name": "uncors", | ||
"version": "0.0.8-beta", | ||
"version": "0.0.9", | ||
"description": "A simple dev HTTP/HTTPS reverse proxy for replacing CORS headers.", | ||
"main": "index.js", | ||
"repository": "git@github.com:evg4b/uncors.git", | ||
"keywords": [ | ||
"cors", | ||
"proxy", | ||
"reverse-proxy", | ||
"http", | ||
"https", | ||
"cli", | ||
"devtool" | ||
], | ||
"homepage": "https://github.com/evg4b/uncors#readme", | ||
"bugs": { | ||
"url": "https://github.com/evg4b/uncors/issues" | ||
}, | ||
"license": "MIT", | ||
"author": "Evgeny Abramovich <evg.abramovitch@gmail.com>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:evg4b/uncors.git" | ||
}, | ||
"scripts": { | ||
"postinstall": "go-npm install", | ||
"preuninstall": "go-npm uninstall" | ||
"postinstall": "npm-go-bin install", | ||
"preuninstall": "npm-go-bin uninstall" | ||
}, | ||
"goBinary": { | ||
"go-bin": { | ||
"name": "uncors", | ||
"path": "./bin", | ||
"url": "https://github.com/evg4b/uncors/releases/download/v{{version}}/uncors_{{version}}_{{platform}}_{{arch}}.tar.gz" | ||
}, | ||
"dependencies": { | ||
"@go-task/go-npm": "^0.1.17" | ||
} | ||
"npm-go-bin": "^0.0.1-beta.1" | ||
}, | ||
"cpu": [ | ||
"x64", | ||
"ia32", | ||
"arm", | ||
"arm64" | ||
], | ||
"os": [ | ||
"darwin", | ||
"linux", | ||
"win32" | ||
] | ||
} |
203
README.md
@@ -0,1 +1,2 @@ | ||
<!--suppress HtmlDeprecatedAttribute --> | ||
<p align="center"> | ||
@@ -13,3 +14,3 @@ <a href="https://github.com/evg4b/uncors" title="uncors"> | ||
</a> | ||
<a href="https://github.com/evg4b/uncors/releases"> | ||
<a href="https://github.com/evg4b/uncors/releases/latest"> | ||
<img alt="GitHub version" src="https://img.shields.io/github/v/tag/evg4b/uncors?label=version"> | ||
@@ -37,7 +38,20 @@ </a> | ||
# Quick Install | ||
# Core features | ||
- CORS header replacement | ||
- HTTPS support | ||
- Wildcard URL request mapping | ||
- Simple request/response mocking | ||
- HTTP/HTTPS proxy support | ||
- *Static file serving ([coming soon...](./ROADMAP.md))* | ||
- *Response caching ([coming soon...](./ROADMAP.md))* | ||
Other new features you can find in [UNCORS roadmap](https://github.com/evg4b/uncors/blob/main/ROADMAP.md) | ||
# Quick Install | ||
## Homebrew (macOS | Linux) | ||
If you are on macOS or Linux and using [Homebrew](https://brew.sh/), you can install uncors with the following one-liner: | ||
If you are on macOS or Linux and using [Homebrew](https://brew.sh/), you can install uncors with the following | ||
one-liner: | ||
@@ -48,3 +62,3 @@ ```bash | ||
## Scoop (Windows) | ||
## Scoop (Windows) | ||
@@ -60,5 +74,5 @@ If you are on Windows and using [Scoop](https://scoop.sh/), you can install uncors with the following commands: | ||
You can install uncors as node package in yout project with the following commands: | ||
To install uncors as a node package in your project, you can use the following commands: | ||
Via npm: | ||
Via npm: | ||
@@ -75,5 +89,6 @@ ```bash | ||
## Binary (Cross-platform) | ||
## Binary (Cross-platform) | ||
Download the appropriate version for your platform from [UNCORS releases page](https://github.com/evg4b/uncors/releases). | ||
Download the appropriate version for your platform | ||
from [UNCORS releases page](https://github.com/evg4b/uncors/releases/latest). | ||
Once downloaded, the binary can be run from anywhere. You don’t need to install it into a global location. | ||
@@ -84,5 +99,5 @@ This works well for shared hosts and other systems where you don’t have a privileged account. | ||
## Docker | ||
## Docker | ||
We currently offer images for Docker https://hub.docker.com/r/evg4b/uncors | ||
We currently offer images for [Docker](https://hub.docker.com/r/evg4b/uncors) | ||
@@ -93,9 +108,10 @@ ```bash | ||
## Source | ||
## Build from source | ||
**Prerequisite Tools** | ||
- Git | ||
- Go (at least Go 1.11) | ||
**Fetch from GitHub** | ||
**Fetch from GitHub** | ||
@@ -116,2 +132,5 @@ UNCORS uses the Go Modules support built into Go 1.11 to build. The easiest way to get started is to clone | ||
# Usage | ||
The following command can be used to start the Uncors proxy server: | ||
``` | ||
@@ -121,68 +140,112 @@ uncors --http-port 8080 --to 'https://github.com' --from 'http://localhost' | ||
## Parameters | ||
## CLI Parameters | ||
* `--from` - Local host with protocol for to the resource from which proxying will take place. | ||
* `--to` - Target host with protocol for to the resource to be proxy. | ||
* `--http-port` - Local HTTP listened port. | ||
* `--https-port` - Local HTTPS listened port. | ||
* `--cert-file` - Path to HTTPS certificate file. | ||
* `--key-file` - Path to matching for certificate private key. | ||
* `--proxy` - HTTP/HTTPS proxy to provide requests to real server (used system by default). | ||
* `--mocks` - File with defined [mocks](#mocks) | ||
* `--debug` - Show debug output. | ||
The following command-line parameters can be used to configure the Uncors proxy server: | ||
## Mocks | ||
* `--from` - Specifies the local host with protocol for the resource from which proxying will take place. | ||
* `--to` - Specifies the target host with protocol for the resource to be proxied. | ||
* `--http-port` or `-p` - Specifies the local HTTP listening port. | ||
* `--https-port` or `-s` - Specifies the local HTTPS listening port. | ||
* `--cert-file` - Specifies the path to the HTTPS certificate file. | ||
* `--key-file` - Specifies the path to the matching certificate private key. | ||
* `--proxy` - Specifies the HTTP/HTTPS proxy to provide requests to the real server (system default is used by default). | ||
* `--config` - Specifies the path to the [configuration file](#configuration-file). | ||
* `--debug` - Enables debug output. | ||
Uncors has endpoint mocks mechanism. | ||
All mocks should be defined in yaml file and passed as parameter `--mocks`. | ||
Currently available path, method, queries and headers filters | ||
(for more information see [gorilla/mux](https://github.com/gorilla/mux#matching-routes) route matching). | ||
Any configuration parameters passed via CLI (except for `--from` and `--to`) will override the corresponding | ||
parameters specified in the configuration file. The `--from` and `--to` parameters will add an additional mapping | ||
to the configuration. | ||
**Mocks file example:** | ||
## Configuration file | ||
Uncors supports a YAML file configuration with the following options: | ||
```yaml | ||
- path: /raw-content-endpont | ||
response: | ||
code: 200 | ||
raw-content: ' | ||
Hello word | ||
' | ||
- path: /file-content-endpont | ||
response: | ||
code: 200 | ||
file: ~/hello-word.json | ||
- path: /raw-content-endpont | ||
method: POST | ||
queries: | ||
param1: param 1 value | ||
param2: param 1 value | ||
headers: | ||
header1: header 1 value | ||
header2: header 2 value | ||
response: | ||
code: 200 | ||
# Base configuration | ||
http-port: 8080 # Local HTTP listened port. | ||
mappings: | ||
http://localhost:3000: https://githib.com | ||
debug: false # Show debug output. | ||
proxy: localhost:8080 | ||
# HTTPS configuration | ||
https-port: 8081 # Local HTTPS listened port. | ||
cert-file: ~/server.crt # Path to HTTPS certificate file. | ||
key-file: ~/server.key # Path to matching for certificate private key. | ||
# Mock definitions are used to generate fake responses for certain endpoints. | ||
mocks: | ||
- path: /hello-word | ||
response: | ||
code: 200 | ||
raw-content: 'Hello word' | ||
``` | ||
#### Mocks configuration | ||
The mocks configuration section in Uncors allows you to define specific endpoints to be mocked, including the response | ||
data and other parameters. Currently, mocks are defined globally for all mappings. Available path, method, queries, and headers filters, | ||
which utilize the [gorilla/mux route matching system](https://github.com/gorilla/mux#matching-routes). | ||
Each endpoint mock requires a path parameter, which defines the URL path for the endpoint. You can also use the method | ||
parameter to define a specific HTTP method for the endpoint. | ||
The queries and headers parameters can be used to specify more detailed URLs that will be mocked. The queries parameter | ||
allows you to define specific query parameters for the URL, while the headers parameter allows you to define specific | ||
HTTP headers. | ||
Here is the structure of the mock configuration: | ||
```yaml | ||
mocks: | ||
- path: <string> | ||
method: <string> | ||
queries: | ||
<string>: <string> | ||
# ... | ||
headers: | ||
header1: header 1 value | ||
header2: header 2 value | ||
raw-content: ' | ||
{ "status": "ok" } | ||
' | ||
- path: /file-content-endpont | ||
method: POST | ||
queries: | ||
param1: param 1 value | ||
param2: param 1 value | ||
headers: | ||
header1: header 1 value | ||
header2: header 2 value | ||
response: | ||
code: 200 | ||
headers: | ||
header1: header 1 value | ||
header2: header 2 value | ||
file: ~/hello-word.json | ||
<string>: <string> | ||
# ... | ||
response: | ||
code: <int> | ||
headers: | ||
<string>: <string> | ||
# ... | ||
delay: <string> | ||
raw-content: <string> | ||
file: <string> | ||
``` | ||
## How it works | ||
- `path` (required) - This property is used to define the URL path that should be mocked. The value should be a string, | ||
such as `/example`. The path can include variables, such as `/users/{id}`, which will match any URL that starts | ||
with `/users/` and has a variable `id` in it. | ||
- `method` (optional) - This property is used to define the HTTP method that should be mocked. | ||
The value should be a string. If this property is not specified, the mock will match any HTTP method. | ||
- `queries` (optional) - This property is used to define specific query parameters that should be matched against the | ||
request URL. The value should be a mapping of query parameters and their values, such as `{"param1": "value1", " | ||
param2": "value2"}`. If this property is not specified, the mock will match any query parameter. | ||
- `headers` (optional): This property is used to define specific HTTP headers that should be matched against the request | ||
headers. The value should be a mapping of header names and their values, such as `{"Content-Type": "application/json"}`. | ||
If this property is not specified, the mock will match any HTTP header. | ||
- `response` (required): This property is used to define the mock response. It should be a mapping that contains the | ||
following properties: | ||
- `code` (optional): This property is used to define the HTTP status code that should be returned in the mock | ||
response. The value should be an integer, such as 200 or 404. If this property is not specified, the mock will use | ||
200 OK status code. | ||
- `headers` (optional): This property is used to define specific HTTP headers that should be returned in the mock | ||
response. The value should be a mapping of header names and their values, such as `{"Content-Type": " | ||
application/json"}`. If this property is not specified, the mock response will have no extra headers. | ||
- `delay` (optional): This property is used to define a delay before sending the mock response. The value should be a | ||
string in the format `<number><unit> <nunmber><units> ...`, where `<number>` is a positive integer and `<unit>` is time units. | ||
Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. For example, `1m 30s` would delay the response by 1 minute and 30 | ||
seconds. If this property is not specified, the mock response will be sent immediately. | ||
- `raw-content` (optional): This property is used to define the raw content that should be returned in the mock | ||
response. The value should be a string, such as `Hello, world!`. If this property is not specified, the mock | ||
response will be empty. | ||
- `file` (optional): This property is used to define the path to a file that contains the mock response content. The | ||
file content will be used as the response content. The value should be a string that specifies the file path, such | ||
as `~/mocks/example.json`. If this property is not specified, the mock response will be empty. | ||
## How it works | ||
```mermaid | ||
@@ -204,6 +267,6 @@ sequenceDiagram | ||
Uncors-->>Server: Real GET, POST, PUT... query | ||
Server->>Uncors: Real responce | ||
Server->>Uncors: Real response | ||
Note over Uncors: Replacing url with source<br/> in headers and cookies | ||
Uncors-->>Client: Data responce | ||
Uncors-->>Client: Data response | ||
end | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
AI-detected potential security risk
Supply chain riskAI has determined that this package may contain potential security issues or vulnerabilities.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
1
263
0
1
12755
3
+ Addednpm-go-bin@^0.0.1-beta.1
+ Addednpm-go-bin@0.0.1(transitive)
- Removed@go-task/go-npm@^0.1.17
- Removed@go-task/go-npm@0.1.18(transitive)