Skip to content

Commit

Permalink
refactor: change method of adding server utils
Browse files Browse the repository at this point in the history
  • Loading branch information
kiki-kanri committed Jan 5, 2024
1 parent 027b066 commit 4f843a4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addServerImportsDir, addServerPlugin, createResolver, defineNuxtModule, useLogger } from '@nuxt/kit';
import { addServerImports, addServerPlugin, createResolver, defineNuxtModule, useLogger } from '@nuxt/kit';
import { defu } from 'defu';

import type { CookieStorageOptions, ModuleOptions, RequiredModuleOptions } from './types';
Expand Down Expand Up @@ -58,7 +58,12 @@ export default defineNuxtModule<ModuleOptions>({
} else if (moduleOptions.storage.keyLength < 16) throw new Error('The storage key length must be 16 or more');
nuxt.options.runtimeConfig.nuxtSession = moduleOptions;
const resolver = createResolver(import.meta.url);
addServerImportsDir(resolver.resolve('./runtime/server/utils'));
const sessionUtilsFilePath = resolver.resolve('./runtime/server/utils/session');
addServerImports([
{ from: sessionUtilsFilePath, name: 'clearH3EventContextSession' },
{ from: sessionUtilsFilePath, name: 'popH3EventContextSession' }
]);

addServerPlugin(resolver.resolve('./runtime/server/plugins/session'));
logger.success('Nuxt session initialization successful.');
}
Expand Down

0 comments on commit 4f843a4

Please sign in to comment.