Skip to content

Commit

Permalink
fix(console): using houdini inline mutations and leveraging cache
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed Jul 6, 2024
1 parent ef9b765 commit 3a63a05
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 42 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ make exec-auth
### Start apps/console

```shell
turbo dev --filter=console
turbo --filter=console dev

# or use `--log-order=stream` to disable TUI
turbo dev --filter=console --log-order=stream
turbo --filter=console --log-order=stream dev

# or start the server and open the app in a new browser tab
turbo dev --filter=console -- --open
turbo --filter=console dev -- --open

# run in debug mode
turbo dev:debug --filter=console
turbo --filter=console dev:debug

# run with a custom inline config
# inline environment variables has higher precedence than ones loaded from .env and .env.local files
Expand Down Expand Up @@ -179,9 +179,9 @@ To create a production version of your app:
```shell
turbo build
# run build
turbo build --filter=playground...
turbo build --filter=playground... --dry
turbo build --filter=playground... --graph
turbo --filter=playground... build
turbo --filter=playground... --dry build
turbo --filter=playground... --graph build
```

Run from the local build directory:
Expand Down
28 changes: 14 additions & 14 deletions apps/console-fb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Demo app build with `tailwind`, `flowbite`, `graphql`, `houdini`, `superforms`
Once you've cloned the project and installed dependencies with `pnpm i`, start a development server:

```shell
turbo dev --filter=./apps/console-fb
turbo --filter=console-fb dev

# or start the server and open the app in a new browser tab
turbo dev --filter=./apps/console-fb -- --open
turbo --filter=console-fb dev -- --open

# run in debug mode
turbo dev:debug --filter=./apps/console-fb
turbo --filter=console-fb dev:debug

# run with a custom inline config
# inline environment variables has higher precedence than ones loaded from .env and .env.local files
Expand Down Expand Up @@ -47,25 +47,25 @@ pnpm audit --fix
Format and lint code

```shell
turbo format --filter=console-fb
turbo lint --filter=console-fb
turbo --filter=console-fb format
turbo --filter=console-fb lint
```

## Testing

### Unit/Component Tests

```shell
turbo test --filter=console-fb
turbo --filter=console-fb test

turbo test:ui --filter=console-fb
turbo --filter=console-fb test:ui
#Then, you can visit the Vitest UI at http://localhost:51204/__vitest__/.

# test coverage
turbo test:coverage --filter=console-fb
turbo --filter=console-fb test:coverage

# updating Snapshots
pnpx vitest -u --filter=console-fb
pnpx -u --filter=console-fb vitest

# test specific folder
pnpx vitest apps/console-fb/src/lib/utils
Expand All @@ -76,7 +76,7 @@ pnpx vitest apps/console-fb/src/lib/utils
### E2E Tests

```shell
turbo test:e2e --filter=console-fb
turbo --filter=console-fb test:e2e
```

## Building
Expand All @@ -86,9 +86,9 @@ To create a production version of your app:
```shell
turbo build
# run build
turbo build --filter=console-fb...
turbo build --filter=console-fb... --dry
turbo build --filter=console-fb... --graph
turbo --filter=console-fb... build
turbo --filter=console-fb... --dry build
turbo --filter=console-fb... --graph build
```

Run from the local build directory:
Expand Down Expand Up @@ -126,7 +126,7 @@ cog bump --auto
To build and publish libs

```shell
turbo build --filter=lib...
turbo --filter=lib... build
cd package
pnpm publish
```
1 change: 0 additions & 1 deletion apps/console/src/routes/(app)/profile/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ export const load: PageLoad = async (event) => {
})),
};
};

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
import { cache } from '$houdini';
import * as m from '$i18n/messages';
import { handleMessage } from '$lib/components/layout/toast-manager';
import { webAuthnSchema } from '$lib/schema/user';
Expand All @@ -14,7 +15,6 @@ import { Loader, LoaderCircle, MoreHorizontal } from 'lucide-svelte';
import SuperDebug, { superForm, setMessage, setError, defaults } from 'sveltekit-superforms';
import type { ErrorStatus } from 'sveltekit-superforms';
import { zod } from 'sveltekit-superforms/adapters';
import { cache } from '$houdini';
// Variables
const log = new Logger('profile:keys:browser');
Expand Down Expand Up @@ -59,10 +59,10 @@ const form = superForm(defaults(zod(webAuthnSchema)), {
} as const;
setMessage(form, message);
handleMessage(message, toastStore);
// Since addSecurityKey() is not using houdini client,
// we have to manually invalidate cache.
// Since addSecurityKey() is not using houdini client,
// we have to manually invalidate cache.
// Mark all type 'authUserSecurityKeys' stale
cache.markStale('authUserSecurityKeys')
cache.markStale('authUserSecurityKeys');
},
});
Expand Down
4 changes: 2 additions & 2 deletions apps/console/src/routes/(auth)/signin/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout } from 'node:timers/promises';
import { PUBLIC_DEFAULT_ORGANIZATION } from '$env/static/public';
import { showMagicLinkLogin, showSocialLogin } from '$lib/flags';
import { i18n } from '$lib/i18n';
Expand All @@ -6,7 +7,6 @@ import { limiter } from '$lib/server/limiter/limiter';
import { setNhostSessionInCookies } from '$lib/server/utils/nhost';
import type { NhostClient, Provider } from '@nhost/nhost-js';
import { Logger } from '@spectacular/utils';
import { setTimeout } from 'node:timers/promises';
import { fail } from '@sveltejs/kit';
import { redirect as redirectWithFlash } from 'sveltekit-flash-message/server';
import { message, setError, superValidate } from 'sveltekit-superforms';
Expand Down Expand Up @@ -113,7 +113,7 @@ export const actions = {
);
}

await sleep(8000);
await setTimeout(8000);

if (!form.valid) return fail(400, { form });

Expand Down
14 changes: 7 additions & 7 deletions apps/playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@ pnpm create svelte@latest apps/my-app
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```shell
turbo dev --filter=playground
turbo --filter=playground dev

# or start the server and open the app in a new browser tab
turbo dev --filter=playground -- --open
turbo --filter=playground dev -- --open
```

## Generate

Generate `i18n` types, `schema.graphql` etc...

```shell
turbo run generate --filter=playground
turbo --filter=playground run generate
```

## Building

To create a production version of your app:

```shell
turbo build --filter=playground...
turbo build --filter=playground... --summarize
turbo build --filter=playground... --dry
turbo build --filter=playground... --graph
turbo --filter=playground... build
turbo --filter=playground... --summarize build
turbo --filter=playground... --dry build
turbo --filter=playground... --graph build
```

You can preview the production build with `turbo preview --filter=playground`.
Expand Down
4 changes: 2 additions & 2 deletions apps/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Any static assets, like images, can be placed in the `public/` directory.
## 🧞 Commands

```shell
turbo dev --filter=web
turbo dev --filter=web -- --verbose
turbo --filter=web dev
turbo --filter=web dev -- --verbose
```

All commands are run from the root of the project, from a terminal:
Expand Down
10 changes: 5 additions & 5 deletions docs/turborepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ Guidelines for configuring `turbo.json`
### Run

```shell
turbo dev --filter=playground
turbo dev --filter=web
turbo dev --filter=docs
turbo dev --filter=console --log-order=stream
turbo --filter=playground dev
turbo --filter=web dev
turbo --filter=docs dev
turbo --filter=console --log-order=stream dev
```

### Test

```shell
turbo test --filter=helpers
turbo --filter=helpers test
```

### Build
Expand Down

0 comments on commit 3a63a05

Please sign in to comment.