Skip to content

Commit

Permalink
doc : improve doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nuzulul committed Jan 25, 2024
1 parent 7677f9e commit 61f970c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

## Demo

[https://codesandbox.io/p/devbox/opencors-lrwj6n](https://codesandbox.io/p/devbox/opencors-lrwj6n)
[https://codesandbox.io/p/devbox/nodejs-cors-proxy-xqsqwg](https://codesandbox.io/p/devbox/nodejs-cors-proxy-xqsqwg)

## Installation

```javascript
npm install opencors
```

## Example
## Example Usage

### Server (NodeJS)

Expand All @@ -42,12 +42,12 @@ const server = new OpenCORS({
```
Request examples:

* `https://lrwj6n-4000.csb.app/?url=https://www.google.com/` - Raw Google.com with CORS headers
* `https://xqsqwg-8080.csb.app/?url=https://www.google.com/` - Raw Google.com with CORS headers

### Client (Browser)

```javascript
fetch('https://lrwj6n-4000.csb.app/?url=https://www.google.com/').then(function (response){
fetch('https://xqsqwg-8080.csb.app/?url=https://www.google.com/').then(function (response){
return response.text()
}).then(function (html){
console.log(html)
Expand All @@ -56,14 +56,6 @@ fetch('https://lrwj6n-4000.csb.app/?url=https://www.google.com/').then(function
})
```

### Test

```javascript
git clone https://github.com/nuzulul/opencors.git
npm install
npm start
```

## License

MIT
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opencors",
"version": "1.0.4",
"version": "1.0.3",
"description": "OpenCORS is a simple NodeJS based CORS Proxy",
"main": "dist/cjs/opencors.js",
"module": "dist/mjs/opencors.js",
Expand All @@ -13,10 +13,10 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
"start": "npm run build && node public/server.js",
"start": "npm run build && node public/test/test/server-test.js",
"build-win": "del /S /Q .\\dist\\* && tsc -p tsconfig-mjs.json && tsc -p tsconfig-cjs.json && echo {\"type\": \"commonjs\"}>dist\\cjs\\package.json && echo {\"type\": \"module\"}>dist\\mjs\\package.json",
"start-ts":"ts-node server.ts",
"dev":"nodemon server.ts",
"dev":"nodemon -e js,ts --watch src --watch test --exec \"npm start\"",
"clean-win":"del /S /Q .\\public && del /S /Q .\\dist && rmdir /S /Q .\\node_modules && rmdir /S /Q .\\test\\cjs\\node_modules && rmdir /S /Q .\\test\\mjs\\node_modules",
"test-win":"npm link && cd .\\test\\cjs && npm install && npm link opencors && cd .\\..\\mjs && npm install && npm link opencors",
"test-cjs":"cd .\\test\\cjs && npm start",
Expand Down
6 changes: 0 additions & 6 deletions server.ts

This file was deleted.

6 changes: 6 additions & 0 deletions test/test/server-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const {OpenCORS} = require('./../../src/opencors')

const server = new OpenCORS({
//port:4000
})

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"target": "es6",
"rootDir": ".",
},
"include": ["server.ts","src"],
"include": ["test/test/server-test.js","src"],
"exclude": ["node_modules", "**/*.spec.ts"]
}

0 comments on commit 61f970c

Please sign in to comment.