Skip to content

Commit

Permalink
fix(nuxt): infer cookie options type from runtimeconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
prazdevs committed Sep 1, 2024
1 parent 1cd32bf commit 565455d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import {
useLogger,
} from '@nuxt/kit'
import { defu } from 'defu'
import type { CookiesStorageOptions } from './runtime/storages'
import type { CookieOptions } from 'nuxt/app'
import type { PersistenceOptions } from './types'

type ModuleOptions = Pick<PersistenceOptions, 'debug'> & {
storage?: 'cookies' | 'localStorage' | 'sessionStorage'
cookieOptions?: CookiesStorageOptions
cookieOptions?: Omit<
CookieOptions,
'encode' | 'decode' | 'default' | 'watch' | 'readonly' | 'filter'
>
}

export default defineNuxtModule<ModuleOptions>({
Expand Down
7 changes: 2 additions & 5 deletions src/runtime/storages.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import type { PublicRuntimeConfig } from 'nuxt/schema'
import type { StorageLike } from '../types'
import type { CookieOptions } from '#app'
import { useCookie } from '#app'

export type CookiesStorageOptions = Omit<
CookieOptions,
'encode' | 'decode' | 'default' | 'watch' | 'readonly' | 'filter'
>
type CookiesStorageOptions = PublicRuntimeConfig['piniaPluginPersistedstate']['cookieOptions']

/**
* Cookie-based storage. Cookie options can be passed as parameter.
Expand Down

0 comments on commit 565455d

Please sign in to comment.