Skip to content

Commit

Permalink
refactor(import): Improve readability by shortening defineProxyParty …
Browse files Browse the repository at this point in the history
…import path with alias
  • Loading branch information
radyakaze committed Oct 1, 2024
1 parent 1245140 commit 3dec82c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To use Nuxt Proxy Party, you need to define your proxy routes within the `server
## Simple
```typescript
import { getCookie } from 'h3'
import { defineProxyParty } from '@radya/nuxt-proxy-party/core'
import { defineProxyParty } from '#nuxt-proxy-party'

export default defineProxyParty([
{
Expand All @@ -50,7 +50,7 @@ export default defineProxyParty([

```typescript
import { getCookie } from 'h3'
import { defineProxyParty } from '@radya/nuxt-proxy-party/core'
import { defineProxyParty } from '#nuxt-proxy-party'

export default defineProxyParty([
{
Expand Down
2 changes: 1 addition & 1 deletion playground/server.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCookie } from 'h3'
import { defineProxyParty } from '../src/core'
import { defineProxyParty } from '#nuxt-proxy-party'
import { useRuntimeConfig } from '#imports'

const config = useRuntimeConfig()
Expand Down
2 changes: 2 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default defineNuxtModule<ModuleOptions>({
async setup(_options, nuxt) {
const resolver = createResolver(import.meta.url)

nuxt.options.alias['#nuxt-proxy-party'] = resolver.resolve('./core')

const serverConfigPath = await resolver.resolvePath('server.config', {
cwd: nuxt.options.rootDir,
extensions: ['.js', '.mjs', '.ts'],
Expand Down
2 changes: 1 addition & 1 deletion template/server.config.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCookie } from 'h3'
import { defineProxyParty } from '@radya/nuxt-proxy-party/core'
import { defineProxyParty } from '#nuxt-proxy-party'

export default defineProxyParty([
{
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/basic/server.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getCookie } from 'h3'
import { defineProxyParty } from '../../../src/core'
import { defineProxyParty } from '#nuxt-proxy-party'

export default defineProxyParty([
{
name: 'bin',
baseUrl: '/api/bin',
target: '/api/example',
target: 'http://httpbin.org',
handler: (event) => {
const token = getCookie(event, 'oauth/token')

Expand Down

0 comments on commit 3dec82c

Please sign in to comment.