-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 79b86d1
Showing
32 changed files
with
11,799 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install dependencies | ||
run: npx nypm@latest i | ||
|
||
- name: Lint | ||
run: npm run lint | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install dependencies | ||
run: npx nypm@latest i | ||
|
||
- name: Playground prepare | ||
run: npm run dev:prepare | ||
|
||
- name: Test | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Dependencies | ||
node_modules | ||
|
||
# Logs | ||
*.log* | ||
|
||
# Temp directories | ||
.temp | ||
.tmp | ||
.cache | ||
|
||
# Yarn | ||
**/.yarn/cache | ||
**/.yarn/*state* | ||
|
||
# Generated dirs | ||
dist | ||
|
||
# Nuxt | ||
.nuxt | ||
.output | ||
.data | ||
.vercel_build_output | ||
.build-* | ||
.netlify | ||
|
||
# Env | ||
.env | ||
|
||
# Testing | ||
reports | ||
coverage | ||
*.lcov | ||
.nyc_output | ||
|
||
# VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# Intellij idea | ||
*.iml | ||
.idea | ||
|
||
# OSX | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
shamefully-hoist=true | ||
strict-peer-dependencies=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eslint.experimental.useFlatConfig": true | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
yarnPath: .yarn/releases/yarn-4.4.0.cjs | ||
|
||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Pringgo Radianto (Radya) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Nuxt Proxy Party | ||
|
||
`Nuxt Proxy Party` is a module designed to simplify the process of creating proxies using `h3-proxy` in your Nuxt application. This module allows you to easily define and manage proxy routes with custom handlers. | ||
|
||
## Installation | ||
|
||
To install `Nuxt Proxy Party`, run the following command: | ||
|
||
```bash | ||
yarn add -D nuxt-proxy-party | ||
``` | ||
|
||
After installation, add the module to your `nuxt.config.ts`: | ||
|
||
```typescript | ||
export default defineNuxtConfig({ | ||
modules: ['nuxt-proxy-party'], | ||
}) | ||
``` | ||
|
||
## Configuration | ||
|
||
To initialize the configuration file, run: | ||
|
||
```bash | ||
npx nuxt-proxy-party --init | ||
``` | ||
|
||
This will create a default configuration file that you can modify to suit your needs. | ||
|
||
## Usage | ||
|
||
To use Nuxt Proxy Party, you need to define your proxy routes within the `server.config.ts` file: | ||
|
||
## Simple | ||
```typescript | ||
import { getCookie } from 'h3' | ||
import { defineProxyParty } from 'nuxt-proxy-party/core' | ||
|
||
export default defineProxyParty([ | ||
{ | ||
name: 'bin', | ||
baseUrl: '/api/bin', | ||
target: 'https://httpbin.org', | ||
}, | ||
]) | ||
``` | ||
|
||
## With custom handler | ||
|
||
```typescript | ||
import { getCookie } from 'h3' | ||
import { defineProxyParty } from 'nuxt-proxy-party/core' | ||
|
||
export default defineProxyParty([ | ||
{ | ||
name: 'bin', | ||
baseUrl: '/api/bin', | ||
target: 'https://httpbin.org', | ||
handler: (event) => { | ||
const token = getCookie(event, 'oauth/token') | ||
|
||
if (token) { | ||
event.node.req.headers.authorization = `Bearer ${token}` | ||
} | ||
}, | ||
}, | ||
]) | ||
``` | ||
|
||
### Using Runtime Config | ||
|
||
If you need to use runtime configuration, import it from `#imports`: | ||
|
||
```typescript | ||
import { useRuntimeConfig } from '#imports' | ||
``` | ||
|
||
This allows you to access and use runtime configuration values in your proxy handler. | ||
|
||
## Contributing | ||
|
||
We welcome contributions to `Nuxt Proxy Party`. If you’d like to contribute, please follow these steps: | ||
|
||
1. **Enable Corepack**: Ensure Corepack is enabled by running: | ||
```bash | ||
corepack enable | ||
``` | ||
|
||
2. **Install Dependencies**: Install all necessary dependencies by running: | ||
```bash | ||
yarn install | ||
``` | ||
|
||
3. **Generate Type Stubs**: Run the following command to generate type stubs: | ||
```bash | ||
yarn dev:prepare | ||
``` | ||
|
||
4. **Start Development Mode**: Use the following command to start the playground in development mode: | ||
```bash | ||
yarn dev | ||
``` | ||
|
||
This will set up your environment to develop and test `Nuxt Proxy Party`. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. | ||
|
||
--- | ||
|
||
This README now includes a section on how to contribute to the project, detailing the setup process for development. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineBuildConfig } from 'unbuild' | ||
|
||
export default defineBuildConfig({ | ||
entries: [ | ||
{ | ||
input: './src/core', | ||
name: 'core', | ||
}, | ||
{ | ||
builder: 'mkdist', | ||
input: 'src/bin', | ||
outDir: 'dist/bin', | ||
} | ||
], | ||
externals: ['h3', 'consola'], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @ts-check | ||
import { createConfigForNuxt } from '@nuxt/eslint-config/flat' | ||
|
||
// Run `npx @eslint/config-inspector` to inspect the resolved config interactively | ||
export default createConfigForNuxt({ | ||
features: { | ||
// Rules for module authors | ||
tooling: true, | ||
// Rules for formatting | ||
stylistic: true, | ||
}, | ||
dirs: { | ||
src: [ | ||
'./playground', | ||
], | ||
}, | ||
}) | ||
.append( | ||
// your custom flat config here... | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "nuxt-proxy-party", | ||
"version": "1.0.0", | ||
"description": "Nuxt HTTP proxy based on H3", | ||
"repository": "radyakaze/nuxt-proxy-party", | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/types.d.ts", | ||
"import": "./dist/module.mjs", | ||
"require": "./dist/module.cjs" | ||
} | ||
}, | ||
"main": "./dist/module.cjs", | ||
"types": "./dist/types.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"bin": "./dist/bin/index.mjs", | ||
"scripts": { | ||
"prepack": "nuxt-module-build build", | ||
"dev": "nuxi dev playground", | ||
"dev:build": "nuxi build playground", | ||
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground", | ||
"release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags", | ||
"lint": "eslint .", | ||
"test": "vitest run", | ||
"test:watch": "vitest watch", | ||
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@nuxt/kit": "^3.12.4", | ||
"citty": "^0.1.6" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/devtools": "^1.3.9", | ||
"@nuxt/eslint-config": "^0.3.13", | ||
"@nuxt/module-builder": "^0.8.1", | ||
"@nuxt/schema": "^3.12.4", | ||
"@nuxt/test-utils": "^3.14.0", | ||
"@types/node": "^20.14.11", | ||
"@vitest/ui": "^2.0.5", | ||
"changelogen": "^0.5.5", | ||
"eslint": "^9.7.0", | ||
"nuxt": "^3.12.4", | ||
"typescript": "latest", | ||
"vitest": "^2.0.5", | ||
"vue-tsc": "^2.0.26" | ||
}, | ||
"packageManager": "yarn@4.4.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template> | ||
<div> | ||
Nuxt module playground! | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default defineNuxtConfig({ | ||
modules: ['../src/module'], | ||
runtimeConfig: { | ||
apiUrl: '', | ||
}, | ||
devtools: { enabled: true }, | ||
compatibilityDate: '2024-08-09', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"private": true, | ||
"name": "my-module-playground", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "nuxi dev", | ||
"build": "nuxi build", | ||
"generate": "nuxi generate" | ||
}, | ||
"dependencies": { | ||
"nuxt": "^3.12.4" | ||
} | ||
} |
Oops, something went wrong.