File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 129129.yarn /build-state.yml
130130.yarn /install-state.gz
131131.pnp. *
132+
133+ .clinic /
Original file line number Diff line number Diff line change 4747 "coverage" : " vitest run src --coverage --config ./vitest.config.ts"
4848 },
4949 "dependencies" : {
50- "@nuxt/kit" : " ^3.12.4 " ,
50+ "@nuxt/kit" : " ^3.13.2 " ,
5151 "axios" : " ^1.7.2" ,
5252 "defu" : " ^6.1.4" ,
5353 "ofetch" : " ^1.3.4" ,
6262 "@nuxt/schema" : " 3.13.2" ,
6363 "@nuxt/test-utils" : " 3.14.2" ,
6464 "@privyid/eslint-config-persona" : " 0.27.0" ,
65- "@privyid/nhp" : " 1.0.0 " ,
65+ "@privyid/nhp" : " 1.0.1 " ,
6666 "@typescript-eslint/eslint-plugin" : " 5.62.0" ,
6767 "@typescript-eslint/parser" : " 5.62.0" ,
6868 "@vitest/coverage-v8" : " ^2.0.5" ,
8585 },
8686 "publishConfig" : {
8787 "access" : " public"
88+ },
89+ "resolutions" : {
90+ "http-proxy" : " npm:http-proxy-node16@1.0.5" ,
91+ "rollup" : " npm:@rollup/wasm-node@*"
8892 }
8993}
Original file line number Diff line number Diff line change 1+ <template >
2+ <h1 >
3+ Heeeelllo Wooorrrlllddd !!!!
4+ </h1 >
5+ </template >
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { defineNuxtPlugin } from '#app'
2+ import { onRequest } from '@privyid/nuapi/core'
3+
4+ export default defineNuxtPlugin ( {
5+ dependsOn : [ 'nuapi:plugin' ] ,
6+ setup ( ) {
7+ onRequest ( ( config ) => {
8+ if ( ! config . headers . Authorization )
9+ config . headers . Authorization = 'Bearer 123456'
10+
11+ return config
12+ } )
13+ } ,
14+ } )
Original file line number Diff line number Diff line change 1+ import { defineEventHandler } from 'h3'
2+ import process from 'node:process'
3+
4+ export default defineEventHandler ( ( ) => {
5+ if ( ! global . gc ) {
6+ return {
7+ code : 400 ,
8+ message : 'GC not available' ,
9+ }
10+ }
11+
12+ const before = process . memoryUsage ( )
13+
14+ global . gc ( )
15+
16+ const after = process . memoryUsage ( )
17+ const diff = {
18+ rss : before . rss - after . rss ,
19+ heapTotal : before . heapTotal - after . heapTotal ,
20+ heapUsed : before . heapUsed - after . heapUsed ,
21+ external : before . external - after . external ,
22+ arrayBuffers : before . arrayBuffers - after . arrayBuffers ,
23+ }
24+
25+ return {
26+ code : 200 ,
27+ message : 'Memory clerer' ,
28+ data : {
29+ before,
30+ after,
31+ diff,
32+ } ,
33+ }
34+ } )
Original file line number Diff line number Diff line change 1+ { "extends" : " ../.nuxt/tsconfig.server.json" }
Original file line number Diff line number Diff line change 11import { createLazyton } from './instance'
2+ import type { ApiResolver } from './types'
3+
4+ let $resolver : ApiResolver
5+
6+ export function setResolver ( resolver : ApiResolver ) {
7+ $resolver = resolver
8+ }
9+
10+ const getApi = createLazyton ( { } , true )
11+
12+ /**
13+ * Set global api instance
14+ * @param instance
15+ */
16+ export const setApi = getApi . setApi
217
318/**
419 * Use global api instance
@@ -7,10 +22,8 @@ import { createLazyton } from './instance'
722 *
823 * api.get('/some/endpoint')
924 */
10- export const useApi = createLazyton ( { } , true )
11-
12- /**
13- * Set global api instance
14- * @param instance
15- */
16- export const setApi = useApi . setApi
25+ export const useApi = ( ) => {
26+ return $resolver
27+ ? $resolver ( )
28+ : getApi ( )
29+ }
Original file line number Diff line number Diff line change @@ -28,20 +28,20 @@ function toValue<T extends object = any> (value: T | (() => T)) {
2828 * useApi().get('/url/endpoint/')
2929 */
3030export function createLazyton ( options : ApiConfig | ( ( ) => ApiConfig ) = { } , fresh = false ) : LazyInstance {
31- let api : ApiInstance
31+ let $ api : ApiInstance
3232
3333 const getApi = function ( ) {
34- if ( ! api ) {
35- api = fresh
34+ if ( ! $ api) {
35+ $ api = fresh
3636 ? createApi ( toValue ( options ) )
3737 : useApi ( ) . create ( toValue ( options ) )
3838 }
3939
40- return api
40+ return $ api
4141 }
4242
4343 const setApi = function ( instance : ApiInstance ) {
44- api = instance
44+ $ api = instance
4545 }
4646
4747 return Object . assign ( getApi , { setApi } )
Original file line number Diff line number Diff line change @@ -107,4 +107,4 @@ export interface ApiInstance extends AxiosInstance {
107107 create : ( this : ApiInstance , config ?: ApiConfig ) => ApiInstance ,
108108}
109109
110- export type ApiResolver = ( ) => ApiInstance | undefined
110+ export type ApiResolver = ( ) => ApiInstance
You can’t perform that action at this time.
0 commit comments