Skip to content

Commit 5ee9517

Browse files
committed
Use /api proxy + convert to tailwindcss v4
1 parent 90e9ec3 commit 5ee9517

File tree

5 files changed

+97
-19
lines changed

5 files changed

+97
-19
lines changed

src/demo/App.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
<SecondaryButton @click="modal = !modal">Modal Dialog</SecondaryButton>
1010
</div>
1111

12+
type=Booking
13+
<AutoQueryGrid ref="grid" type="Booking" />
14+
!end=Booking
15+
1216
<div class="mt-8 mx-auto max-w-4xl flex flex-col gap-y-4">
1317
<h3>date</h3>
1418
<div class="grid grid-cols-6 gap-6">
@@ -502,20 +506,20 @@
502506
<pre>{{ createBooking }}</pre>
503507
</form>
504508

505-
<form class="mb-3" @submit.prevent="">
509+
<!-- <form class="mb-3" @submit.prevent="">
506510
<input type="submit" class="hidden">
507511
<h3 class="text-lg">CreateJobApplication</h3>
508512
<AutoFormFields v-model="createJobApplication" :api="createJobApplicationApi" @update:modelValue="$forceUpdate" />
509513
<pre>{{ createJobApplication }}</pre>
510-
</form>
514+
</form> -->
511515

512-
<form class="mb-3" @submit.prevent="">
516+
<!--form class="mb-3" @submit.prevent="">
513517
<input type="submit" class="hidden">
514518
<h3 class="text-lg">AllTypes</h3>
515519
<AutoFormFields v-model="allTypes" :api="allTypesApi" @update:modelValue="$forceUpdate" />
516520
<AutoEditForm v-model="allTypesJson" formStyle="card" type="AllTypes" />
517521
<pre>{{ allTypes }}</pre>
518-
</form>
522+
</form-->
519523
</div>
520524

521525
<div class="mx-auto max-w-4xl">
@@ -702,6 +706,7 @@ import { AllTypes, Authenticate,
702706
} from './dtos'
703707
import Combobox from '../components/Combobox.vue'
704708
import SecondaryButton from '../components/SecondaryButton.vue'
709+
// import metadataJson from './app.json'
705710
706711
function classes(type:'array'|'object', tag:'div'|'table'|'thead'|'th'|'tr'|'td',depth:number,cls:string,index?:number) {
707712
if (type == 'array') {
@@ -732,13 +737,20 @@ const booking = bookingObject[0]
732737
733738
const { dateInputFormat, setRef } = useUtils()
734739
const { setConfig, setAutoQueryGridDefaults } = useConfig()
735-
const { loadMetadata, metadataApi, enumOptions } = useMetadata()
740+
const { loadMetadata, metadataApi, enumOptions, setMetadata } = useMetadata()
736741
const { Formats, currency, formatDate, relativeTime } = useFormatters()
737742
743+
// setMetadata(metadataJson)
744+
745+
const client = inject<JsonServiceClient>('client')!
746+
747+
authenticate()
748+
738749
loadMetadata({
739750
olderThan: 60 * 60 * 1000,
751+
client,
740752
//resolvePath: 'https://localhost:5001/metadata/app.json',
741-
resolvePath: 'https://blazor-gallery.servicestack.net/metadata/app.json',
753+
//resolvePath: 'https://blazor-gallery.servicestack.net/metadata/app.json',
742754
})
743755
744756
setConfig({
@@ -786,10 +798,6 @@ const dynamicDates:{[k:string]:InputInfo} = Object.keys(dates).reduce((acc,x) =>
786798
modelDates.value[x] = dates[x]
787799
return acc }, {})
788800
789-
const client = inject<JsonServiceClient>('client')!
790-
791-
authenticate()
792-
793801
const autoFormRequest = new QueryBookings({
794802
skip: 1,
795803
take: 2,

src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createRouter, createWebHistory } from "vue-router"
33
import './tailwind.css'
44
import App from './demo/App.vue'
55
import ServiceStackVue from '.'
6-
import { JsonApiClient } from '@servicestack/client'
6+
import { JsonServiceClient } from '@servicestack/client'
77

88
const colorScheme = localStorage.getItem('color-scheme')
99
if (colorScheme === 'dark') {
@@ -17,9 +17,11 @@ const router = createRouter({
1717
routes: [],
1818
})
1919

20+
// const client = new JsonServiceClient('https://blazor-gallery.servicestack.net')
21+
const client = new JsonServiceClient()
2022

2123
createApp(App)
2224
.use(ServiceStackVue)
2325
.use(router)
24-
.provide('client', JsonApiClient.create('http://localhost:5000'))
26+
.provide('client', client)
2527
.mount('#app')

src/tailwind.css

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
@tailwind base;
2-
@tailwind components;
3-
@tailwind utilities;
1+
@import "tailwindcss";
2+
@plugin "@tailwindcss/forms";
43

5-
.svg-external {
4+
@variant dark (&:where(.dark, .dark *));
5+
6+
@layer base {
7+
:root {
8+
color-scheme: light;
9+
}
10+
11+
.dark {
12+
color-scheme: dark;
13+
}
14+
}
15+
16+
@layer utilities {
17+
.svg-external {
618
color: #007bff;
719
background: url("data:image/svg+xml,%3Csvg width='1.25rem' height='1.25rem' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none'%3E%3Cpath d='M10 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4M14 4h6m0 0v6m0-6L10 14' stroke='%23007bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/g%3E%3C/svg%3E") no-repeat bottom right;
820
padding-right: 1.35rem;
9-
}
10-
.svg-external:hover {
21+
}
22+
.svg-external:hover {
1123
text-decoration: underline;
24+
}
1225
}

tailwind.config.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* Tailwind CSS v4 Configuration
3+
*
4+
* Note: In Tailwind CSS v4, configuration is now CSS-first.
5+
* This file is kept for backward compatibility but is not actively used.
6+
* All configuration is now done in src/tailwind.css using @theme and @plugin directives.
7+
*
8+
* See: https://tailwindcss.com/docs/upgrade-guide
9+
*/
10+
111
/** @type {import('tailwindcss').Config} */
212
module.exports = {
313
content: ['./src/**/*.{vue,js,ts,jsx,tsx}'],
@@ -6,6 +16,8 @@ module.exports = {
616
extend: {},
717
},
818
plugins: [
19+
// Note: In v4, plugins are imported in CSS using @plugin directive
20+
// See src/tailwind.css for the actual plugin configuration
921
require('@tailwindcss/forms'),
1022
],
1123
}

vite.config.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@ import { fileURLToPath, URL } from 'node:url'
44
import { defineConfig } from 'vite'
55
import vue from '@vitejs/plugin-vue'
66
import dts from 'vite-plugin-dts'
7+
8+
import fs from 'fs'
9+
import path from 'path'
10+
import { env } from 'process'
11+
12+
13+
const baseFolder =
14+
env.APPDATA !== undefined && env.APPDATA !== ''
15+
? `${env.APPDATA}/ASP.NET/https`
16+
: `${env.HOME}/.aspnet/https`;
17+
18+
const certificateArg = process.argv.map(arg => arg.match(/--name=(?<value>.+)/i)).filter(Boolean)[0];
19+
const certificateName = certificateArg ? certificateArg!.groups!.value : "myapp.client";
20+
21+
if (!certificateName) {
22+
console.error('Invalid certificate name. Run this script in the context of an npm/yarn script or pass --name=<<app>> explicitly.')
23+
process.exit(-1);
24+
}
25+
26+
const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
27+
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
28+
29+
const target = env.ASPNETCORE_HTTPS_PORT ? `https://localhost:${env.ASPNETCORE_HTTPS_PORT}` :
30+
env.ASPNETCORE_URLS ? env.ASPNETCORE_URLS.split(';')[0] : 'https://localhost:5001';
31+
const apiUrl = process.env.NODE_ENV === 'development' ? target : ''
32+
const baseUrl = process.env.NODE_ENV === 'development'
33+
? "https://locahost:5173"
34+
: process.env.DEPLOY_HOST ? `https://${process.env.DEPLOY_HOST}` : undefined
735

836
// https://vitejs.dev/config/
937
export default defineConfig({
@@ -37,5 +65,20 @@ export default defineConfig({
3765
alias: {
3866
'@': fileURLToPath(new URL('./src', import.meta.url))
3967
}
40-
}
68+
},
69+
server: {
70+
proxy: {
71+
'^/api': {
72+
target,
73+
secure: false
74+
}
75+
},
76+
port: 5173,
77+
...(fs.existsSync(keyFilePath) && fs.existsSync(certFilePath) ? {
78+
https: {
79+
key: fs.readFileSync(keyFilePath),
80+
cert: fs.readFileSync(certFilePath),
81+
}
82+
} : {})
83+
}
4184
})

0 commit comments

Comments
 (0)