Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nuxt to devdependencies #125

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/sdk-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@
"vue": ">=3.0.0"
},
"devDependencies": {
"@fusionauth-sdk/core": "*",
"@testing-library/vue": "^8.0.2",
"@types/node": "^18.11.18",
"@vitejs/plugin-vue": "^4.2.3",
"@vue/test-utils": "^2.4.4",
"jsdom": "^24.0.0",
"minimist": "1.2.8",
"nuxt": "^3.12.1",
"sass": "1.65.1",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-dts": "3.5.1",
"vitest": "^1.3.1",
"vue": "^3.0.0",
"vue-docgen-web-types": "0.1.8",
"vue-tsc": "^1.8.5",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^3.17.1",
"@fusionauth-sdk/core": "*"
"vue-tsc": "^1.8.5"
},
"files": [
"dist/*"
Expand Down
9 changes: 3 additions & 6 deletions packages/sdk-vue/src/createFusionAuth/NuxtUseCookieAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { CookieAdapter } from '@fusionauth-sdk/core';
import { useCookie as useCookieType } from 'nuxt/app';

/**
* See docs for more info [useCookie](https://nuxt.com/docs/api/composables/use-cookie).
*/
export class NuxtUseCookieAdapter implements CookieAdapter {
constructor(private useCookie: UseCookie) {
constructor(private useCookie: typeof useCookieType) {
this.useCookie = useCookie;
}

at_exp(cookieName: string = 'app.at_exp') {
// useCookie must be invoked with the cookie name every time to get the up-to-date value
return this.useCookie(cookieName).value;
return this.useCookie(cookieName).value ?? undefined;
}
}

export type UseCookie = (key: string) => {
value: string | number | undefined;
};
6 changes: 3 additions & 3 deletions packages/sdk-vue/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Ref } from 'vue';
import { UseCookie } from './createFusionAuth/NuxtUseCookieAdapter';
import { useCookie as useCookieType } from 'nuxt/app';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to import as here because there's no name collision in this file.


/**
* Config for the FusionAuth Vue SDK
Expand Down Expand Up @@ -54,10 +54,10 @@ export interface FusionAuthConfig {
onAutoRefreshFailure?: (error: Error) => void;

/**
* Pass in `useCookie` from nuxt/app [useCookie](https://nuxt.com/docs/api/composables/use-cookie).
* Pass in `useCookieType` from nuxt/app [useCookie](https://nuxt.com/docs/api/composables/use-cookie).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment shouldn't be changed because the thing they need to pass in is still called useCookie

* This is needed for the Vue SDK to support Nuxt/SSR.
*/
nuxtUseCookie?: UseCookie;
nuxtUseCookie?: typeof useCookieType;

/**
* The path to the login endpoint.
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
fileName: 'vue-fusionauth',
},
rollupOptions: {
external: ['vue'],
external: ['vue', 'nuxt'],
dmackinn marked this conversation as resolved.
Show resolved Hide resolved
output: {
globals: {
vue: 'Vue',
Expand Down
Loading