Skip to content

fix(ssr): remove mentioning of internal packages #8282

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

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import {
} from 'aws-amplify/auth';
import { list } from 'aws-amplify/storage';
import { generateClient } from 'aws-amplify/api';
import outputs from '../amplify_outputs.json';
import config from '../amplify_outputs.json';

const client = generateClient<Schema>();

Expand Down Expand Up @@ -122,17 +122,14 @@ Example implementation:
import type { CookieRef } from 'nuxt/app';
import type { Schema } from '~/amplify/data/resource';
import type { ListPaginateWithPathInput } from 'aws-amplify/storage';
import type {
LibraryOptions,
FetchAuthSessionOptions
} from '@aws-amplify/core';
import {
createKeyValueStorageFromCookieStorageAdapter,
createUserPoolsTokenProvider,
createAWSCredentialsAndIdentityIdProvider,
runWithAmplifyServerContext
} from 'aws-amplify/adapter-core';
import { parseAmplifyConfig } from 'aws-amplify/utils';
import type { FetchAuthSessionOptions } from 'aws-amplify/auth';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, can we move this type import above the value imports?

Copy link
Member Author

Choose a reason for hiding this comment

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

@josefaidt sorted & grouped all the imports.

import {
fetchAuthSession,
fetchUserAttributes,
Expand All @@ -141,10 +138,10 @@ import {
import { list } from 'aws-amplify/storage/server';
import { generateClient } from 'aws-amplify/api/server';

import outputs from '../amplify_outputs.json';
import config from '../amplify_outputs.json';

// parse the content of `amplify_outputs.json` into the shape of ResourceConfig
const amplifyConfig = parseAmplifyConfig(outputs);
const amplifyConfig = parseAmplifyConfig(config);

// create the Amplify used token cookies names array
const userPoolClientId = amplifyConfig.Auth!.Cognito.userPoolClientId;
Expand Down Expand Up @@ -273,7 +270,7 @@ export default defineNuxtPlugin({
);

// Create the libraryOptions object
const libraryOptions: LibraryOptions = {
const libraryOptions = {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this type available from the main package?

Copy link
Member Author

Choose a reason for hiding this comment

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

@josefaidt This type is not available in the main package. In this example it's not necessary, since tokenProvider and credentialsProvider are typed individually

Auth: {
tokenProvider,
credentialsProvider
Expand Down Expand Up @@ -423,7 +420,7 @@ Example implementation:

```ts title="plugins/02.authRedirect.ts"
import { Amplify } from 'aws-amplify';
import outputs from '~/amplify_outputs.json';
import config from '~/amplify_outputs.json';

// Amplify.configure() only needs to be called on the client side
if (process.client) {
Expand Down Expand Up @@ -494,8 +491,7 @@ import {
} from 'aws-amplify/adapter-core';
import { parseAmplifyConfig } from 'aws-amplify/utils';

import type { LibraryOptions } from '@aws-amplify/core';
import outputs from '~/amplify_outputs.json';
import config from '~/amplify_outputs.json';

const amplifyConfig = parseAmplifyConfig(config);

Expand Down Expand Up @@ -527,7 +523,7 @@ const createCookieStorageAdapter = (

const createLibraryOptions = (
event: H3Event<EventHandlerRequest>
): LibraryOptions => {
) => {
const cookieStorage = createCookieStorageAdapter(event);
const keyValueStorage =
createKeyValueStorageFromCookieStorageAdapter(cookieStorage);
Expand Down