Skip to content

Commit

Permalink
refactor: rename useConfig to useRuntimeConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 7, 2022
1 parent 00177d0 commit 1d31ec9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const nitroImports: Preset[] = [
imports: [
'defineCachedFunction',
'defineCachedEventHandler',
'useConfig',
'useRuntimeConfig',
'useStorage',
'useNitroApp',
'defineNitroPlugin',
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import destr from 'destr'
import { createRouter as createMatcher } from 'radix3'
import { createCall, createFetch as createLocalFetch } from 'unenv/runtime/fetch/index'
import { createHooks, Hookable } from 'hookable'
import { useConfig } from './config'
import { useRuntimeConfig } from './config'
import { timingMiddleware } from './timing'
import { cachedEventHandler } from './cache'
import { plugins } from '#nitro/virtual/plugins'
Expand All @@ -19,7 +19,7 @@ export interface NitroApp {
}

function createNitroApp (): NitroApp {
const config = useConfig()
const config = useRuntimeConfig()

const hooks = createHooks()

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for (const key in _runtimeConfig) {

// Named exports
const config = deepFreeze(_runtimeConfig)
export const useConfig = () => config
export const useRuntimeConfig = () => config
export default config

// Utils
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/entries/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getAssetFromKV, mapRequestToAsset } from '@cloudflare/kv-asset-handler'
import { withoutBase } from 'ufo'
import { requestHasBody, useRequestBody } from '../utils'
import { nitroApp } from '../app'
import { useConfig } from '#nitro'
import { useRuntimeConfig } from '#nitro'

addEventListener('fetch', (event: any) => {
event.respondWith(handleEvent(event))
Expand Down Expand Up @@ -53,6 +53,6 @@ function assetsCacheControl (_request) {
}

const baseURLModifier = (request: Request) => {
const url = withoutBase(request.url, useConfig().app.baseURL)
const url = withoutBase(request.url, useRuntimeConfig().app.baseURL)
return mapRequestToAsset(new Request(url, request))
}
4 changes: 2 additions & 2 deletions src/runtime/entries/node-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Server as HttpServer } from 'http'
import { Server as HttpsServer } from 'https'
import destr from 'destr'
import { nitroApp } from '../app'
import { useConfig } from '#nitro'
import { useRuntimeConfig } from '#nitro'

const cert = process.env.NITRO_SSL_CERT
const key = process.env.NITRO_SSL_KEY
Expand All @@ -20,7 +20,7 @@ server.listen(port, hostname, (err) => {
process.exit(1)
}
const protocol = cert && key ? 'https' : 'http'
console.log(`Listening on ${protocol}://${hostname}:${port}${useConfig().app.baseURL}`)
console.log(`Listening on ${protocol}://${hostname}:${port}${useRuntimeConfig().app.baseURL}`)
})

export default {}
2 changes: 1 addition & 1 deletion src/runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { useStorage } from '#nitro/virtual/storage'
export { useConfig } from './config'
export { useRuntimeConfig } from './config'
export { defineCachedFunction, defineCachedEventHandler } from './cache'
export { useNitroApp } from './app'
export * from './plugin'

0 comments on commit 1d31ec9

Please sign in to comment.