-
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.
Merge pull request #24 from privy-open-source/fix/plugin-priority
- Loading branch information
Showing
12 changed files
with
1,941 additions
and
857 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,95 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
merge_group: | ||
types: [checks_requested] | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ${{ matrix.os }} | ||
|
||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
language: | ||
- javascript | ||
|
||
steps: | ||
- name: Git Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
- name: Run CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
|
||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
node-version: | ||
- 18 | ||
|
||
steps: | ||
- name: Git Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: "recursive" | ||
|
||
- name: Get Cache Dir | ||
id: yarn-cache-dir | ||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | ||
|
||
- name: Use Cache | ||
uses: actions/cache@v3 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir.outputs.dir }} | ||
key: ${{ runner.os }}-yarn- | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "yarn" | ||
|
||
- name: Install Deps | ||
run: yarn install --immutable | ||
|
||
- name: Run Prepare | ||
run: yarn dev:prepare | ||
|
||
- name: Run Test | ||
run: yarn coverage | ||
|
||
- name: Build Package | ||
run: yarn build | ||
|
||
- name: Run Linter | ||
run: yarn lint |
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
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,7 @@ | ||
import { createLazyton } from '@privyid/nuapi/core' | ||
|
||
const useApi = createLazyton({ prefixURL: '/api' }) | ||
|
||
export async function getUser () { | ||
return await useApi().get('/users') | ||
} |
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 |
---|---|---|
@@ -1,19 +1,7 @@ | ||
<template> | ||
<div> | ||
Nuxt module playground! | ||
<pre>{{ users }}</pre> | ||
<NuxtLayout> | ||
<NuxtPage /> | ||
</NuxtLayout> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { onMounted, ref } from 'vue' | ||
import { useApi } from '../src/core' | ||
const users = ref([]) | ||
onMounted(async () => { | ||
const { data } = await useApi().get('https://reqres.in/api/users') | ||
users.value = data | ||
}) | ||
</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
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 @@ | ||
<template> | ||
<h1>Hello Index.vue</h1> | ||
<button @click="refresh()"> | ||
Reload | ||
</button> | ||
<pre v-if="pending">Loading...</pre> | ||
<pre v-else>{{ data }}</pre> | ||
</template> | ||
|
||
<script setup> | ||
import { useApi } from '@privyid/nuapi/core' | ||
import { useAsyncData } from '#app' | ||
const { data, refresh, pending } = await useAsyncData('users', async () => { | ||
const { data } = await useApi().get('/api/users') | ||
return data | ||
}, | ||
) | ||
</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,6 @@ | ||
import { defineNuxtPlugin } from '#app' | ||
import { getUser } from '../api/coba' | ||
|
||
export default defineNuxtPlugin(async () => { | ||
await getUser() | ||
}) |
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,9 @@ | ||
import { defineServer } from '@privyid/nhp/core' | ||
|
||
export default defineServer([ | ||
{ | ||
name : 'coba', | ||
baseUrl : '/api', | ||
targetUrl: 'https://reqres.in/api', | ||
}, | ||
]) |
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
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
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,43 @@ | ||
import { | ||
useRuntimeConfig, | ||
useRequestEvent, | ||
defineNuxtPlugin, | ||
} from '#imports' | ||
import { | ||
type ApiConfig, | ||
type ApiInstance, | ||
createApi, | ||
setApi, | ||
} from '@privyid/nuapi/core' | ||
import getURL from 'requrl' | ||
import { joinURL } from 'ufo' | ||
|
||
declare module 'h3' { | ||
interface H3Event { | ||
$api?: ApiInstance, | ||
} | ||
} | ||
|
||
export default defineNuxtPlugin(() => { | ||
const event = useRequestEvent() | ||
const config = useRuntimeConfig() | ||
|
||
let instance = event.$api | ||
|
||
if (!instance) { | ||
const host = getURL(event?.node?.req) | ||
const baseURL = joinURL(host, config.app.baseURL) | ||
|
||
const options: ApiConfig = { | ||
baseURL, | ||
headers: { 'accept-encoding': 'gzip, deflate' }, | ||
} | ||
|
||
instance = createApi(options) | ||
event.$api = instance | ||
} | ||
|
||
setApi(instance) | ||
|
||
return { provide: { api: instance } } | ||
}) |
Oops, something went wrong.