Skip to content

Releases: wpengine/faustjs

@faustjs/[email protected]

06 Oct 22:20
98c45b0
Compare
Choose a tag to compare

Patch Changes

  • 1e32f81: Typeings for getNextStaticProps and getNextServerSideProps now allow and protect custom props.

@faustjs/[email protected]

06 Oct 18:41
78a5b3a
Compare
Choose a tag to compare

Patch Changes

  • 7d30277: logQueries is can now be called and will log GraphQL queries if desired.

@faustjs/[email protected]

05 Oct 19:58
980253a
Compare
Choose a tag to compare

Minor Changes

  • 8243e9f: headlessConfig from @faustjs/core is now just config, and @faustjs/next has its own config with a global revalidate option.

    Your faust.config.js needs to change to look like this:

    import { config as coreConfig } from '@faustjs/core';
    
    if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
      console.error(
        'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?',
      );
    }
    
    /**
     * @type {import("@faustjs/core").Config}
     */
    export default coreConfig({
      wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
      apiClientSecret: process.env.WP_HEADLESS_SECRET,
    });

    Or, to configure the global revalidate option in @faustjs/next:

    import { config as coreConfig } from '@faustjs/core';
    import { config as nextConfig } from '@faustjs/next';
    
    if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
      console.error(
        'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?',
      );
    }
    
    nextConfig({
      revalidate: 60, // 1 minute
    });
    
    /**
     * @type {import("@faustjs/core").Config}
     */
    export default coreConfig({
      wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
      apiClientSecret: process.env.WP_HEADLESS_SECRET,
    });

    NOTE: @faustjs/next defaults to revalidate: 900 (15 minutes).

Patch Changes

@faustjs/[email protected]

05 Oct 19:58
980253a
Compare
Choose a tag to compare

Minor Changes

  • 8243e9f: headlessConfig from @faustjs/core is now just config, and @faustjs/next has its own config with a global revalidate option.

    Your faust.config.js needs to change to look like this:

    import { config as coreConfig } from '@faustjs/core';
    
    if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
      console.error(
        'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?',
      );
    }
    
    /**
     * @type {import("@faustjs/core").Config}
     */
    export default coreConfig({
      wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
      apiClientSecret: process.env.WP_HEADLESS_SECRET,
    });

    Or, to configure the global revalidate option in @faustjs/next:

    import { config as coreConfig } from '@faustjs/core';
    import { config as nextConfig } from '@faustjs/next';
    
    if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
      console.error(
        'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?',
      );
    }
    
    nextConfig({
      revalidate: 60, // 1 minute
    });
    
    /**
     * @type {import("@faustjs/core").Config}
     */
    export default coreConfig({
      wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
      apiClientSecret: process.env.WP_HEADLESS_SECRET,
    });

    NOTE: @faustjs/next defaults to revalidate: 900 (15 minutes).

  • 5c7f662: Introduced an argument to the useAuth hook, UseAuthOptions, to provide users the ability to disable automatic redirect from the useAuth hook upon an unauthenticated user.

    import { client } from 'client';
    
    export default function Page() {
      const { isLoading, isAuthenticated, authResult } = client.auth.useAuth({
        shouldRedirect: false,
      });
    
      if (isLoading) {
        return <p>Loading...</p>;
      }
    
      if (!isAuthenticated) {
        return (
          <p>You need to be authenticated to see this content. Please login.</p>
        );
      }
    
      return <p>Authenticated content</p>;
    }

Patch Changes

@faustjs/[email protected]

05 Oct 19:58
980253a
Compare
Choose a tag to compare

Minor Changes

  • 4ded997: Implement logoutHandler middleware

  • 8243e9f: headlessConfig from @faustjs/core is now just config, and @faustjs/next has its own config with a global revalidate option.

    Your faust.config.js needs to change to look like this:

    import { config as coreConfig } from '@faustjs/core';
    
    if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
      console.error(
        'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?',
      );
    }
    
    /**
     * @type {import("@faustjs/core").Config}
     */
    export default coreConfig({
      wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
      apiClientSecret: process.env.WP_HEADLESS_SECRET,
    });

    Or, to configure the global revalidate option in @faustjs/next:

    import { config as coreConfig } from '@faustjs/core';
    import { config as nextConfig } from '@faustjs/next';
    
    if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
      console.error(
        'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?',
      );
    }
    
    nextConfig({
      revalidate: 60, // 1 minute
    });
    
    /**
     * @type {import("@faustjs/core").Config}
     */
    export default coreConfig({
      wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
      apiClientSecret: process.env.WP_HEADLESS_SECRET,
    });

    NOTE: @faustjs/next defaults to revalidate: 900 (15 minutes).

  • f0f2706: Introduced the apiRouter that will handle all of the Faust.js related endpoints for you.

    Breaking Changes

    With the introduction of apiRouter we have introduced a breaking change. You will need to remove your pages/api/auth/wpe-headless.ts file, and create a new file, pages/api/faust/[[...route]].ts with the following content:

    import 'faust.config';
    import { apiRouter } from '@faustjs/core/api';
    
    export default apiRouter;

    Note: The [[...route]] naming convention is a Next.js convention for a catch-all route.

    Config changes

    The apiEndpoint and apiUrl config options have been removed in exchange for the apiBasePath option. This option specifies the base path for all of the Faust.js endpoints. The blogUrlPrefix is no longer necessary and has been removed from the config interface.

Patch Changes

  • c4b205a: Implemented changesets 🦋
  • 5c7f662: Added the appropriate Content-Type response header to the authorizeHandler middleware

package/core/0.11.0

23 Sep 19:37
f7bd788
Compare
Choose a tag to compare
Refactor `next/getting-started` example to 0.11.0 (#497)

* Update example starter schema

* Update Faust.js to 0.11.0

package/core/0.10.2

14 Sep 20:45
96621e1
Compare
Choose a tag to compare
Releasing 0.10.2 (#453)

* chore: 0.10.2

* fix: allowing npm i to pass

* fix: npm audit

* fix: tests passing

package/core/0.10.1

14 Sep 20:44
d8a1723
Compare
Choose a tag to compare
Increment packages to 0.10.1 (#449)

package/core/0.10.0

08 Sep 16:01
79291fe
Compare
Choose a tag to compare

Release 0.10.0 of the NPM packages include BREAKING CHANGES. Existing users of Faust.js will need to make the following changes:

Step 1 - Update the WPE Headless Plugin

Ensure that you are on version 0.6.0 or later of the WPE Headless Plugin.

Step 2 - Update preview.tsx file

If you started from the next/getting-started example, replace the contents of src/pages/preview.tsx with the following:

import { PageComponent } from './[...pageUri]';
import { PostComponent } from './posts/[postSlug]';
import { client } from 'client';

export default function Preview() {
  const { usePreview } = client.auth;
  const result = usePreview();

  if (client.useIsLoading() || !result) {
    return <p>loading...</p>;
  }

  if (result.type === 'page') {
    if (!result.page) {
      return <>Not Found</>;
    }

    return <PageComponent page={result.page} />;
  }

  if (!result.post) {
    return <>Not Found</>;
  }

  return <PostComponent post={result.post} />;
}

Step 3 - Create next.config.js file

In the root of your project, alongside package.json, create a next.config.js file with the following contents:

const { withFaust } = require('@faustjs/next');

/**
 * @type {import('next').NextConfig}
 **/
module.exports = withFaust();

If you already have an existing next.config.js file, you can place it within the first argument of the withFaust function, like so:

const { withFaust } = require('@faustjs/next');

/**
 * @type {import('next').NextConfig}
 **/
module.exports = withFaust({
    // Your Next.js config here
});

Step 4 - Update gqty.config.js file

In the root of your project, alongside package.json, replace the gqty.config.js file with the following:

require('dotenv').config();

/**
 * @type {import("@gqty/cli").GQtyConfig}
 */
const config = {
  react: false,
  scalarTypes: { DateTime: 'string' },
  introspection: {
    endpoint: `${process.env.NEXT_PUBLIC_WORDPRESS_URL}/graphql`,
    headers: {},
  },
  destination: './src/client/index.ts',
  subscriptions: false,
  javascriptOutput: false,
};

console.log(`Using "${config.introspection.endpoint}" to generate schema...`);

module.exports = config;

package/core/0.9.0

27 Aug 21:09
7c2abd0
Compare
Choose a tag to compare

Release package/core/0.9.0

Release 0.9.0 of the NPM packages include BREAKING CHANGES. Existing users of Faust.js will need to update their faust.config.js file to use ESM syntax, opposed to CJS syntax.

For example, users will need to replace their current faust.config.js file:

const { headlessConfig } = require('@faustjs/core');

if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
  console.error(
    'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env file?',
  );
}

/**
 * @type {import("@faustjs/core").HeadlessConfig}
 */
module.exports = headlessConfig({
  wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
  apiClientSecret: process.env.WP_HEADLESS_SECRET,
});

With the following code:

import { headlessConfig } from '@faustjs/core';

if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
  console.error(
    'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env file?',
  );
}

/**
 * @type {import("@faustjs/core").HeadlessConfig}
 */
export default headlessConfig({
  wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
  apiClientSecret: process.env.WP_HEADLESS_SECRET,
});