From 6ab00206df2e2b57b1063d29770cd826827e11ea Mon Sep 17 00:00:00 2001 From: trev Date: Thu, 13 Mar 2025 06:35:51 -0400 Subject: [PATCH] feat: prettier tailwind --- client/.prettierrc | 5 +- client/README.md | 38 -------------- client/package-lock.json | 80 +++++++++++++++++++++++++++++ client/package.json | 1 + client/src/lib/transport.ts | 26 ++++++++++ client/src/routes/+page.svelte | 4 +- client/src/routes/auth/+page.svelte | 29 +++++++++++ 7 files changed, 142 insertions(+), 41 deletions(-) delete mode 100644 client/README.md create mode 100644 client/src/lib/transport.ts create mode 100644 client/src/routes/auth/+page.svelte diff --git a/client/.prettierrc b/client/.prettierrc index 3f7802c..b19073e 100644 --- a/client/.prettierrc +++ b/client/.prettierrc @@ -3,7 +3,10 @@ "singleQuote": true, "trailingComma": "none", "printWidth": 100, - "plugins": ["prettier-plugin-svelte"], + "plugins": [ + "prettier-plugin-svelte", + "prettier-plugin-tailwindcss" + ], "overrides": [ { "files": "*.svelte", diff --git a/client/README.md b/client/README.md deleted file mode 100644 index b5b2950..0000000 --- a/client/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# sv - -Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). - -## Creating a project - -If you're seeing this, you've probably already done this step. Congrats! - -```bash -# create a new project in the current directory -npx sv create - -# create a new project in my-app -npx sv create my-app -``` - -## Developing - -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: - -```bash -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open -``` - -## Building - -To create a production version of your app: - -```bash -npm run build -``` - -You can preview the production build with `npm run preview`. - -> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. diff --git a/client/package-lock.json b/client/package-lock.json index 5f26dfc..79778b1 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -23,6 +23,7 @@ "globals": "^16.0.0", "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.3", + "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.0.0", "svelte-check": "^4.0.0", "tailwindcss": "^4.0.13", @@ -3381,6 +3382,85 @@ "svelte": "^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0" } }, + "node_modules/prettier-plugin-tailwindcss": { + "version": "0.6.11", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.11.tgz", + "integrity": "sha512-YxaYSIvZPAqhrrEpRtonnrXdghZg1irNg4qrjboCXrpybLWVs55cW2N3juhspVJiO0JBvYJT8SYsJpc8OQSnsA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.21.3" + }, + "peerDependencies": { + "@ianvs/prettier-plugin-sort-imports": "*", + "@prettier/plugin-pug": "*", + "@shopify/prettier-plugin-liquid": "*", + "@trivago/prettier-plugin-sort-imports": "*", + "@zackad/prettier-plugin-twig": "*", + "prettier": "^3.0", + "prettier-plugin-astro": "*", + "prettier-plugin-css-order": "*", + "prettier-plugin-import-sort": "*", + "prettier-plugin-jsdoc": "*", + "prettier-plugin-marko": "*", + "prettier-plugin-multiline-arrays": "*", + "prettier-plugin-organize-attributes": "*", + "prettier-plugin-organize-imports": "*", + "prettier-plugin-sort-imports": "*", + "prettier-plugin-style-order": "*", + "prettier-plugin-svelte": "*" + }, + "peerDependenciesMeta": { + "@ianvs/prettier-plugin-sort-imports": { + "optional": true + }, + "@prettier/plugin-pug": { + "optional": true + }, + "@shopify/prettier-plugin-liquid": { + "optional": true + }, + "@trivago/prettier-plugin-sort-imports": { + "optional": true + }, + "@zackad/prettier-plugin-twig": { + "optional": true + }, + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-css-order": { + "optional": true + }, + "prettier-plugin-import-sort": { + "optional": true + }, + "prettier-plugin-jsdoc": { + "optional": true + }, + "prettier-plugin-marko": { + "optional": true + }, + "prettier-plugin-multiline-arrays": { + "optional": true + }, + "prettier-plugin-organize-attributes": { + "optional": true + }, + "prettier-plugin-organize-imports": { + "optional": true + }, + "prettier-plugin-sort-imports": { + "optional": true + }, + "prettier-plugin-style-order": { + "optional": true + }, + "prettier-plugin-svelte": { + "optional": true + } + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/client/package.json b/client/package.json index 9d9ac32..1cdba86 100644 --- a/client/package.json +++ b/client/package.json @@ -29,6 +29,7 @@ "globals": "^16.0.0", "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.3", + "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.0.0", "svelte-check": "^4.0.0", "tailwindcss": "^4.0.13", diff --git a/client/src/lib/transport.ts b/client/src/lib/transport.ts new file mode 100644 index 0000000..5257e14 --- /dev/null +++ b/client/src/lib/transport.ts @@ -0,0 +1,26 @@ +import { createConnectTransport } from "@connectrpc/connect-web" +import { Code, ConnectError, createClient } from "@connectrpc/connect" +import { AuthService } from "$lib/services/user/v1/auth_pb"; +import { UserService } from "$lib/services/user/v1/user_pb"; +import type { Interceptor } from "@connectrpc/connect"; +import { goto } from "$app/navigation"; + +const redirector: Interceptor = (next) => async (req) => { + try { + return await next(req); + } catch (e) { + const error = ConnectError.from(e); + if (error.code === Code.Unauthenticated) { + await goto('/auth'); + } + throw e; + } +}; + +const transport = createConnectTransport({ + baseUrl: `${window.location.origin}/grpc`, + interceptors: [redirector], +}); + +export const AuthClient = createClient(AuthService, transport); +export const UserClient = createClient(UserService, transport); \ No newline at end of file diff --git a/client/src/routes/+page.svelte b/client/src/routes/+page.svelte index cc88df0..b67ac5f 100644 --- a/client/src/routes/+page.svelte +++ b/client/src/routes/+page.svelte @@ -1,2 +1,2 @@ -

Welcome to SvelteKit

-

Visit svelte.dev/docs/kit to read the documentation

+

Welcome to TrevStack

+

Visit github.com/spotdemo4/trevstack to read the documentation

diff --git a/client/src/routes/auth/+page.svelte b/client/src/routes/auth/+page.svelte new file mode 100644 index 0000000..ae11c7c --- /dev/null +++ b/client/src/routes/auth/+page.svelte @@ -0,0 +1,29 @@ + + +
+ + + + Outbound + + + Inbound + + + Test1 + Test2 + +