litestar-vite 0.1.1__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- litestar_vite/__init__.py +54 -4
- litestar_vite/__metadata__.py +12 -7
- litestar_vite/cli.py +1048 -10
- litestar_vite/codegen/__init__.py +48 -0
- litestar_vite/codegen/_export.py +229 -0
- litestar_vite/codegen/_inertia.py +619 -0
- litestar_vite/codegen/_openapi.py +280 -0
- litestar_vite/codegen/_routes.py +720 -0
- litestar_vite/codegen/_ts.py +235 -0
- litestar_vite/codegen/_utils.py +141 -0
- litestar_vite/commands.py +73 -0
- litestar_vite/config/__init__.py +997 -0
- litestar_vite/config/_constants.py +97 -0
- litestar_vite/config/_deploy.py +70 -0
- litestar_vite/config/_inertia.py +241 -0
- litestar_vite/config/_paths.py +63 -0
- litestar_vite/config/_runtime.py +235 -0
- litestar_vite/config/_spa.py +93 -0
- litestar_vite/config/_types.py +94 -0
- litestar_vite/deploy.py +366 -0
- litestar_vite/doctor.py +1181 -0
- litestar_vite/exceptions.py +78 -0
- litestar_vite/executor.py +360 -0
- litestar_vite/handler/__init__.py +9 -0
- litestar_vite/handler/_app.py +612 -0
- litestar_vite/handler/_routing.py +130 -0
- litestar_vite/html_transform.py +569 -0
- litestar_vite/inertia/__init__.py +77 -0
- litestar_vite/inertia/_utils.py +119 -0
- litestar_vite/inertia/exception_handler.py +178 -0
- litestar_vite/inertia/helpers.py +1571 -0
- litestar_vite/inertia/middleware.py +54 -0
- litestar_vite/inertia/plugin.py +199 -0
- litestar_vite/inertia/precognition.py +274 -0
- litestar_vite/inertia/request.py +334 -0
- litestar_vite/inertia/response.py +802 -0
- litestar_vite/inertia/types.py +335 -0
- litestar_vite/loader.py +464 -123
- litestar_vite/plugin/__init__.py +687 -0
- litestar_vite/plugin/_process.py +185 -0
- litestar_vite/plugin/_proxy.py +689 -0
- litestar_vite/plugin/_proxy_headers.py +244 -0
- litestar_vite/plugin/_static.py +37 -0
- litestar_vite/plugin/_utils.py +489 -0
- litestar_vite/py.typed +0 -0
- litestar_vite/scaffolding/__init__.py +20 -0
- litestar_vite/scaffolding/generator.py +270 -0
- litestar_vite/scaffolding/templates.py +437 -0
- litestar_vite/templates/__init__.py +0 -0
- litestar_vite/templates/addons/tailwindcss/tailwind.css.j2 +1 -0
- litestar_vite/templates/angular/index.html.j2 +12 -0
- litestar_vite/templates/angular/openapi-ts.config.ts.j2 +18 -0
- litestar_vite/templates/angular/package.json.j2 +36 -0
- litestar_vite/templates/angular/src/app/app.component.css.j2 +3 -0
- litestar_vite/templates/angular/src/app/app.component.html.j2 +1 -0
- litestar_vite/templates/angular/src/app/app.component.ts.j2 +9 -0
- litestar_vite/templates/angular/src/app/app.config.ts.j2 +5 -0
- litestar_vite/templates/angular/src/main.ts.j2 +9 -0
- litestar_vite/templates/angular/src/styles.css.j2 +9 -0
- litestar_vite/templates/angular/tsconfig.app.json.j2 +34 -0
- litestar_vite/templates/angular/tsconfig.json.j2 +20 -0
- litestar_vite/templates/angular/vite.config.ts.j2 +21 -0
- litestar_vite/templates/angular-cli/.postcssrc.json.j2 +5 -0
- litestar_vite/templates/angular-cli/angular.json.j2 +36 -0
- litestar_vite/templates/angular-cli/openapi-ts.config.ts.j2 +18 -0
- litestar_vite/templates/angular-cli/package.json.j2 +28 -0
- litestar_vite/templates/angular-cli/proxy.conf.json.j2 +18 -0
- litestar_vite/templates/angular-cli/src/app/app.component.css.j2 +3 -0
- litestar_vite/templates/angular-cli/src/app/app.component.html.j2 +1 -0
- litestar_vite/templates/angular-cli/src/app/app.component.ts.j2 +9 -0
- litestar_vite/templates/angular-cli/src/app/app.config.ts.j2 +5 -0
- litestar_vite/templates/angular-cli/src/index.html.j2 +13 -0
- litestar_vite/templates/angular-cli/src/main.ts.j2 +6 -0
- litestar_vite/templates/angular-cli/src/styles.css.j2 +10 -0
- litestar_vite/templates/angular-cli/tailwind.config.js.j2 +4 -0
- litestar_vite/templates/angular-cli/tsconfig.app.json.j2 +16 -0
- litestar_vite/templates/angular-cli/tsconfig.json.j2 +26 -0
- litestar_vite/templates/angular-cli/tsconfig.spec.json.j2 +9 -0
- litestar_vite/templates/astro/astro.config.mjs.j2 +28 -0
- litestar_vite/templates/astro/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/astro/src/layouts/Layout.astro.j2 +63 -0
- litestar_vite/templates/astro/src/pages/index.astro.j2 +36 -0
- litestar_vite/templates/astro/src/styles/global.css.j2 +1 -0
- litestar_vite/templates/base/.gitignore.j2 +42 -0
- litestar_vite/templates/base/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/base/package.json.j2 +39 -0
- litestar_vite/templates/base/resources/vite-env.d.ts.j2 +1 -0
- litestar_vite/templates/base/tsconfig.json.j2 +37 -0
- litestar_vite/templates/htmx/src/main.js.j2 +8 -0
- litestar_vite/templates/htmx/templates/base.html.j2.j2 +56 -0
- litestar_vite/templates/htmx/templates/index.html.j2.j2 +13 -0
- litestar_vite/templates/htmx/vite.config.ts.j2 +40 -0
- litestar_vite/templates/nuxt/app.vue.j2 +29 -0
- litestar_vite/templates/nuxt/composables/useApi.ts.j2 +33 -0
- litestar_vite/templates/nuxt/nuxt.config.ts.j2 +31 -0
- litestar_vite/templates/nuxt/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/nuxt/pages/index.vue.j2 +54 -0
- litestar_vite/templates/react/index.html.j2 +13 -0
- litestar_vite/templates/react/src/App.css.j2 +56 -0
- litestar_vite/templates/react/src/App.tsx.j2 +19 -0
- litestar_vite/templates/react/src/main.tsx.j2 +10 -0
- litestar_vite/templates/react/vite.config.ts.j2 +39 -0
- litestar_vite/templates/react-inertia/index.html.j2 +14 -0
- litestar_vite/templates/react-inertia/package.json.j2 +47 -0
- litestar_vite/templates/react-inertia/resources/App.css.j2 +68 -0
- litestar_vite/templates/react-inertia/resources/main.tsx.j2 +17 -0
- litestar_vite/templates/react-inertia/resources/pages/Home.tsx.j2 +18 -0
- litestar_vite/templates/react-inertia/resources/ssr.tsx.j2 +19 -0
- litestar_vite/templates/react-inertia/vite.config.ts.j2 +59 -0
- litestar_vite/templates/react-router/index.html.j2 +12 -0
- litestar_vite/templates/react-router/src/App.css.j2 +17 -0
- litestar_vite/templates/react-router/src/App.tsx.j2 +7 -0
- litestar_vite/templates/react-router/src/main.tsx.j2 +10 -0
- litestar_vite/templates/react-router/vite.config.ts.j2 +39 -0
- litestar_vite/templates/react-tanstack/index.html.j2 +12 -0
- litestar_vite/templates/react-tanstack/openapi-ts.config.ts.j2 +18 -0
- litestar_vite/templates/react-tanstack/src/App.css.j2 +17 -0
- litestar_vite/templates/react-tanstack/src/main.tsx.j2 +21 -0
- litestar_vite/templates/react-tanstack/src/routeTree.gen.ts.j2 +7 -0
- litestar_vite/templates/react-tanstack/src/routes/__root.tsx.j2 +9 -0
- litestar_vite/templates/react-tanstack/src/routes/books.tsx.j2 +9 -0
- litestar_vite/templates/react-tanstack/src/routes/index.tsx.j2 +9 -0
- litestar_vite/templates/react-tanstack/vite.config.ts.j2 +39 -0
- litestar_vite/templates/svelte/index.html.j2 +13 -0
- litestar_vite/templates/svelte/src/App.svelte.j2 +30 -0
- litestar_vite/templates/svelte/src/app.css.j2 +45 -0
- litestar_vite/templates/svelte/src/main.ts.j2 +8 -0
- litestar_vite/templates/svelte/src/vite-env.d.ts.j2 +2 -0
- litestar_vite/templates/svelte/svelte.config.js.j2 +5 -0
- litestar_vite/templates/svelte/vite.config.ts.j2 +39 -0
- litestar_vite/templates/svelte-inertia/index.html.j2 +14 -0
- litestar_vite/templates/svelte-inertia/resources/app.css.j2 +21 -0
- litestar_vite/templates/svelte-inertia/resources/main.ts.j2 +11 -0
- litestar_vite/templates/svelte-inertia/resources/pages/Home.svelte.j2 +43 -0
- litestar_vite/templates/svelte-inertia/resources/vite-env.d.ts.j2 +2 -0
- litestar_vite/templates/svelte-inertia/svelte.config.js.j2 +5 -0
- litestar_vite/templates/svelte-inertia/vite.config.ts.j2 +37 -0
- litestar_vite/templates/sveltekit/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/sveltekit/src/app.css.j2 +40 -0
- litestar_vite/templates/sveltekit/src/app.html.j2 +12 -0
- litestar_vite/templates/sveltekit/src/hooks.server.ts.j2 +55 -0
- litestar_vite/templates/sveltekit/src/routes/+layout.svelte.j2 +12 -0
- litestar_vite/templates/sveltekit/src/routes/+page.svelte.j2 +34 -0
- litestar_vite/templates/sveltekit/svelte.config.js.j2 +12 -0
- litestar_vite/templates/sveltekit/tsconfig.json.j2 +14 -0
- litestar_vite/templates/sveltekit/vite.config.ts.j2 +31 -0
- litestar_vite/templates/vue/env.d.ts.j2 +7 -0
- litestar_vite/templates/vue/index.html.j2 +13 -0
- litestar_vite/templates/vue/src/App.vue.j2 +28 -0
- litestar_vite/templates/vue/src/main.ts.j2 +5 -0
- litestar_vite/templates/vue/src/style.css.j2 +45 -0
- litestar_vite/templates/vue/vite.config.ts.j2 +39 -0
- litestar_vite/templates/vue-inertia/env.d.ts.j2 +7 -0
- litestar_vite/templates/vue-inertia/index.html.j2 +14 -0
- litestar_vite/templates/vue-inertia/package.json.j2 +50 -0
- litestar_vite/templates/vue-inertia/resources/main.ts.j2 +18 -0
- litestar_vite/templates/vue-inertia/resources/pages/Home.vue.j2 +22 -0
- litestar_vite/templates/vue-inertia/resources/ssr.ts.j2 +21 -0
- litestar_vite/templates/vue-inertia/resources/style.css.j2 +21 -0
- litestar_vite/templates/vue-inertia/vite.config.ts.j2 +59 -0
- litestar_vite-0.15.0.dist-info/METADATA +230 -0
- litestar_vite-0.15.0.dist-info/RECORD +164 -0
- {litestar_vite-0.1.1.dist-info → litestar_vite-0.15.0.dist-info}/WHEEL +1 -1
- litestar_vite/config.py +0 -100
- litestar_vite/plugin.py +0 -45
- litestar_vite/template_engine.py +0 -103
- litestar_vite-0.1.1.dist-info/METADATA +0 -68
- litestar_vite-0.1.1.dist-info/RECORD +0 -11
- {litestar_vite-0.1.1.dist-info → litestar_vite-0.15.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{ project_name }}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build{% if use_typescript %} && {% if framework in ['vue', 'vue-inertia'] %}vue-tsc -b --noEmit{% else %}tsc -b --noEmit{% endif %}{% endif %}",
|
|
8
|
+
"preview": "vite preview",
|
|
9
|
+
"serve": "vite preview",
|
|
10
|
+
"watch": "npm run serve",
|
|
11
|
+
"update": "npm update"{% if generate_client %},
|
|
12
|
+
"generate-types": "openapi-ts"{% endif %}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
{%- for dep in dependencies %}
|
|
16
|
+
"{{ dep }}": "latest"{% if not loop.last or generate_zod or generate_client %},{% endif %}
|
|
17
|
+
{%- endfor %}
|
|
18
|
+
{%- if generate_client %}
|
|
19
|
+
"axios": "^1.13.2"{% if generate_zod %},{% endif %}
|
|
20
|
+
{%- endif %}
|
|
21
|
+
{%- if generate_zod %}
|
|
22
|
+
"zod": "^4.1.13"
|
|
23
|
+
{%- endif %}
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
{%- for dep in dev_dependencies %}
|
|
27
|
+
"{{ dep }}": "latest",
|
|
28
|
+
{%- endfor %}
|
|
29
|
+
{%- if use_tailwind %}
|
|
30
|
+
"@tailwindcss/vite": "^4.1.17",
|
|
31
|
+
"tailwindcss": "^4.1.17",
|
|
32
|
+
{%- endif %}
|
|
33
|
+
{%- if generate_client %}
|
|
34
|
+
"@hey-api/openapi-ts": "^0.88.0",
|
|
35
|
+
{%- endif %}
|
|
36
|
+
"litestar-vite-plugin": "latest",
|
|
37
|
+
"vite": "^7.2.6"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"moduleDetection": "force",
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
{% if framework in ["react", "react-inertia", "react-router", "react-tanstack"] %}
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"types": ["vite/client"],
|
|
18
|
+
{% elif framework == "vue" or framework == "vue-inertia" %}
|
|
19
|
+
"jsx": "preserve",
|
|
20
|
+
{% endif %}
|
|
21
|
+
|
|
22
|
+
/* Linting */
|
|
23
|
+
"strict": true,
|
|
24
|
+
"noUnusedLocals": true,
|
|
25
|
+
"noUnusedParameters": true,
|
|
26
|
+
"noFallthroughCasesInSwitch": true,
|
|
27
|
+
"noUncheckedSideEffectImports": true,
|
|
28
|
+
|
|
29
|
+
/* Paths */
|
|
30
|
+
"baseUrl": ".",
|
|
31
|
+
"paths": {
|
|
32
|
+
"@/*": ["./{{ resource_dir }}/*"]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"include": ["{{ resource_dir }}/**/*", "vite.config.ts"{% if framework == "vue" or framework == "vue-inertia" %}, "env.d.ts"{% endif %}],
|
|
36
|
+
"exclude": ["{{ resource_dir }}/generated/**"]
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>{% raw %}{% block title %}{% endraw %}{{ "{{ project_name }}" }}{% raw %}{% endblock %}{% endraw %}</title>
|
|
7
|
+
{{ "{{ vite_hmr() }}" }}
|
|
8
|
+
{{ "{{ vite('resources/main.js') }}" }}
|
|
9
|
+
<style>
|
|
10
|
+
:root {
|
|
11
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
12
|
+
line-height: 1.5;
|
|
13
|
+
font-weight: 400;
|
|
14
|
+
color-scheme: light dark;
|
|
15
|
+
color: rgba(255, 255, 255, 0.87);
|
|
16
|
+
background-color: #242424;
|
|
17
|
+
}
|
|
18
|
+
.app {
|
|
19
|
+
max-width: 1280px;
|
|
20
|
+
margin: 0 auto;
|
|
21
|
+
padding: 2rem;
|
|
22
|
+
text-align: center;
|
|
23
|
+
}
|
|
24
|
+
.card {
|
|
25
|
+
padding: 2em;
|
|
26
|
+
}
|
|
27
|
+
button {
|
|
28
|
+
border-radius: 8px;
|
|
29
|
+
border: 1px solid transparent;
|
|
30
|
+
padding: 0.6em 1.2em;
|
|
31
|
+
font-size: 1em;
|
|
32
|
+
font-weight: 500;
|
|
33
|
+
font-family: inherit;
|
|
34
|
+
background-color: #1a1a1a;
|
|
35
|
+
color: inherit;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
transition: border-color 0.25s;
|
|
38
|
+
}
|
|
39
|
+
button:hover {
|
|
40
|
+
border-color: #3d72b4;
|
|
41
|
+
}
|
|
42
|
+
@media (prefers-color-scheme: light) {
|
|
43
|
+
:root {
|
|
44
|
+
color: #213547;
|
|
45
|
+
background-color: #ffffff;
|
|
46
|
+
}
|
|
47
|
+
button {
|
|
48
|
+
background-color: #f9f9f9;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
52
|
+
</head>
|
|
53
|
+
<body>
|
|
54
|
+
{% raw %}{% block content %}{% endraw %}{% raw %}{% endblock %}{% endraw %}
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{% raw %}{% extends "base.html.j2" %}{% endraw %}
|
|
2
|
+
|
|
3
|
+
{% raw %}{% block content %}{% endraw %}
|
|
4
|
+
<main class="app">
|
|
5
|
+
<h1>{{ "{{ project_name }}" }}</h1>
|
|
6
|
+
<div class="card">
|
|
7
|
+
<button hx-get="/api/hello" hx-target="#greeting" hx-swap="innerHTML">
|
|
8
|
+
Load Greeting from API
|
|
9
|
+
</button>
|
|
10
|
+
<p id="greeting"></p>
|
|
11
|
+
</div>
|
|
12
|
+
</main>
|
|
13
|
+
{% raw %}{% endblock %}{% endraw %}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import litestar from "litestar-vite-plugin";
|
|
3
|
+
{% if use_tailwind %}
|
|
4
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
5
|
+
{% endif %}
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
server: {
|
|
9
|
+
host: "0.0.0.0",
|
|
10
|
+
port: Number(process.env.VITE_PORT || "{{ vite_port }}"),
|
|
11
|
+
cors: true,
|
|
12
|
+
hmr: {
|
|
13
|
+
host: "localhost",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
plugins: [
|
|
17
|
+
{% if use_tailwind %}
|
|
18
|
+
tailwindcss(),
|
|
19
|
+
{% endif %}
|
|
20
|
+
litestar({
|
|
21
|
+
input: ["{{ resource_dir }}/main.js"],
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
build: {
|
|
25
|
+
rollupOptions: {
|
|
26
|
+
onwarn(warning, warn) {
|
|
27
|
+
// Suppress eval warnings from htmx (htmx uses eval for dynamic attribute evaluation)
|
|
28
|
+
if (warning.code === "EVAL" && warning.id?.includes("htmx")) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
warn(warning);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
resolve: {
|
|
36
|
+
alias: {
|
|
37
|
+
"@": "/{{ resource_dir }}",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NuxtLayout>
|
|
3
|
+
<NuxtPage />
|
|
4
|
+
</NuxtLayout>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
10
|
+
line-height: 1.5;
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
|
|
13
|
+
color-scheme: light dark;
|
|
14
|
+
color: rgba(255, 255, 255, 0.87);
|
|
15
|
+
background-color: #242424;
|
|
16
|
+
|
|
17
|
+
font-synthesis: none;
|
|
18
|
+
text-rendering: optimizeLegibility;
|
|
19
|
+
-webkit-font-smoothing: antialiased;
|
|
20
|
+
-moz-osx-font-smoothing: grayscale;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@media (prefers-color-scheme: light) {
|
|
24
|
+
:root {
|
|
25
|
+
color: #213547;
|
|
26
|
+
background-color: #ffffff;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composable for making API requests to the Litestar backend.
|
|
3
|
+
* In development, requests are proxied through the Nuxt dev server.
|
|
4
|
+
* In production, requests go directly to the API server.
|
|
5
|
+
*/
|
|
6
|
+
export function useApi() {
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
|
|
9
|
+
const apiBase = process.client
|
|
10
|
+
? "/api" // In browser, use proxy
|
|
11
|
+
: (config.public.apiBase as string) || "http://localhost:{{ litestar_port }}/api";
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
/**
|
|
15
|
+
* Make a GET request to the API.
|
|
16
|
+
*/
|
|
17
|
+
async get<T>(path: string): Promise<T> {
|
|
18
|
+
const { data } = await useFetch<T>(`${apiBase}${path}`);
|
|
19
|
+
return data.value as T;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Make a POST request to the API.
|
|
24
|
+
*/
|
|
25
|
+
async post<T>(path: string, body: unknown): Promise<T> {
|
|
26
|
+
const { data } = await useFetch<T>(`${apiBase}${path}`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
body,
|
|
29
|
+
});
|
|
30
|
+
return data.value as T;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{% if use_tailwind %}
|
|
2
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
3
|
+
{% endif %}
|
|
4
|
+
|
|
5
|
+
// Litestar manages the dev server port via VITE_PORT and runtime config.
|
|
6
|
+
// The Nuxt module reads the port automatically - no hardcoding needed.
|
|
7
|
+
// LITESTAR_PORT is the backend API server port (default {{ litestar_port }}).
|
|
8
|
+
const LITESTAR_PORT = process.env.LITESTAR_PORT ?? "{{ litestar_port }}";
|
|
9
|
+
|
|
10
|
+
export default defineNuxtConfig({
|
|
11
|
+
compatibilityDate: "2024-11-01",
|
|
12
|
+
devtools: { enabled: true },
|
|
13
|
+
modules: ["litestar-vite-plugin/nuxt"],
|
|
14
|
+
{% if use_tailwind %}
|
|
15
|
+
css: ["~/assets/css/tailwind.css"],
|
|
16
|
+
vite: {
|
|
17
|
+
plugins: [tailwindcss()],
|
|
18
|
+
},
|
|
19
|
+
{% endif %}
|
|
20
|
+
litestar: {
|
|
21
|
+
// API proxy points to the Litestar backend (apiPrefix defaults to "/api")
|
|
22
|
+
apiProxy: `http://127.0.0.1:${LITESTAR_PORT}`,
|
|
23
|
+
{% if enable_types %}
|
|
24
|
+
// Type generation config (defaults are "types/api", "openapi.json", "routes.json")
|
|
25
|
+
types: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
output: "types/api",
|
|
28
|
+
},
|
|
29
|
+
{% endif %}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from "@hey-api/openapi-ts";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
input: "./generated/openapi.json",
|
|
5
|
+
output: "./generated/api",
|
|
6
|
+
plugins: [
|
|
7
|
+
"@hey-api/typescript",
|
|
8
|
+
"@hey-api/schemas",
|
|
9
|
+
"@hey-api/sdk",
|
|
10
|
+
"@hey-api/client-nuxt",
|
|
11
|
+
{%- if generate_zod %}
|
|
12
|
+
"zod",
|
|
13
|
+
{%- endif %}
|
|
14
|
+
],
|
|
15
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const count = ref(0);
|
|
3
|
+
|
|
4
|
+
function increment() {
|
|
5
|
+
count.value += 1;
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div class="app">
|
|
11
|
+
<h1>{{ "{{ project_name }}" }}</h1>
|
|
12
|
+
<p>Nuxt 3 + Litestar</p>
|
|
13
|
+
<div class="card">
|
|
14
|
+
<button @click="increment">
|
|
15
|
+
count is {{ "{{ count }}" }}
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<style scoped>
|
|
22
|
+
.app {
|
|
23
|
+
max-width: 1280px;
|
|
24
|
+
margin: 0 auto;
|
|
25
|
+
padding: 2rem;
|
|
26
|
+
text-align: center;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.card {
|
|
30
|
+
padding: 2em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
button {
|
|
34
|
+
border-radius: 8px;
|
|
35
|
+
border: 1px solid transparent;
|
|
36
|
+
padding: 0.6em 1.2em;
|
|
37
|
+
font-size: 1em;
|
|
38
|
+
font-weight: 500;
|
|
39
|
+
font-family: inherit;
|
|
40
|
+
background-color: #1a1a1a;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
transition: border-color 0.25s;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
button:hover {
|
|
46
|
+
border-color: #00dc82;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media (prefers-color-scheme: light) {
|
|
50
|
+
button {
|
|
51
|
+
background-color: #f9f9f9;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>{{ project_name }}</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/{{ resource_dir }}/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.app {
|
|
17
|
+
max-width: 1280px;
|
|
18
|
+
margin: 0 auto;
|
|
19
|
+
padding: 2rem;
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.card {
|
|
24
|
+
padding: 2em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
button {
|
|
28
|
+
border-radius: 8px;
|
|
29
|
+
border: 1px solid transparent;
|
|
30
|
+
padding: 0.6em 1.2em;
|
|
31
|
+
font-size: 1em;
|
|
32
|
+
font-weight: 500;
|
|
33
|
+
font-family: inherit;
|
|
34
|
+
background-color: #1a1a1a;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
transition: border-color 0.25s;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
button:hover {
|
|
40
|
+
border-color: #646cff;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
button:focus,
|
|
44
|
+
button:focus-visible {
|
|
45
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media (prefers-color-scheme: light) {
|
|
49
|
+
:root {
|
|
50
|
+
color: #213547;
|
|
51
|
+
background-color: #ffffff;
|
|
52
|
+
}
|
|
53
|
+
button {
|
|
54
|
+
background-color: #f9f9f9;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
function App() {
|
|
4
|
+
const [count, setCount] = useState(0);
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
<div className="app">
|
|
8
|
+
<h1>{{ project_name }}</h1>
|
|
9
|
+
<p>React + Litestar + Vite</p>
|
|
10
|
+
<div className="card">
|
|
11
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
12
|
+
count is {count}
|
|
13
|
+
</button>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default App;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import litestar from "litestar-vite-plugin";
|
|
4
|
+
{% if use_tailwind %}
|
|
5
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
6
|
+
{% endif %}
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
server: {
|
|
10
|
+
host: "0.0.0.0",
|
|
11
|
+
port: Number(process.env.VITE_PORT || "{{ vite_port }}"),
|
|
12
|
+
cors: true,
|
|
13
|
+
hmr: {
|
|
14
|
+
host: "localhost",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
plugins: [
|
|
18
|
+
{% if use_tailwind %}
|
|
19
|
+
tailwindcss(),
|
|
20
|
+
{% endif %}
|
|
21
|
+
react(),
|
|
22
|
+
litestar({
|
|
23
|
+
input: ["{{ resource_dir }}/main.tsx"],
|
|
24
|
+
{% if enable_types %}
|
|
25
|
+
types: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
output: "{{ resource_dir }}/generated/types",
|
|
28
|
+
generateZod: true,
|
|
29
|
+
generateSdk: true,
|
|
30
|
+
},
|
|
31
|
+
{% endif %}
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
resolve: {
|
|
35
|
+
alias: {
|
|
36
|
+
"@": "/{{ resource_dir }}",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/static/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title inertia>{{ project_name }}</title>
|
|
8
|
+
{{ "{{ vite_hmr() }}" }}
|
|
9
|
+
{{ "{{ vite('{{ resource_dir }}/main.tsx') }}" }}
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app" data-page='{{ "{{ inertia | safe }}" }}'></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{ project_name }}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
{% if enable_ssr %}
|
|
8
|
+
"build": "vite build{% if use_typescript %} && tsc -b --noEmit{% endif %} && vite build --ssr {{ resource_dir }}/ssr.tsx",
|
|
9
|
+
{% else %}
|
|
10
|
+
"build": "vite build{% if use_typescript %} && tsc -b --noEmit{% endif %}",
|
|
11
|
+
{% endif %}
|
|
12
|
+
"preview": "vite preview",
|
|
13
|
+
{% if enable_ssr %}
|
|
14
|
+
"serve": "NODE_ENV=production node {{ resource_dir }}/bootstrap/ssr/ssr.js",
|
|
15
|
+
{% else %}
|
|
16
|
+
"serve": "vite preview",
|
|
17
|
+
{% endif %}
|
|
18
|
+
"watch": "npm run serve",
|
|
19
|
+
"update": "npm update"{% if generate_client %},
|
|
20
|
+
"generate-types": "openapi-ts"{% endif %}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
{%- for dep in dependencies %}
|
|
24
|
+
"{{ dep }}": "latest"{% if not loop.last or generate_zod or generate_client %},{% endif %}
|
|
25
|
+
{%- endfor %}
|
|
26
|
+
{%- if generate_client %}
|
|
27
|
+
"axios": "^1.13.2"{% if generate_zod %},{% endif %}
|
|
28
|
+
{%- endif %}
|
|
29
|
+
{%- if generate_zod %}
|
|
30
|
+
"zod": "^4.1.13"
|
|
31
|
+
{%- endif %}
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
{%- for dep in dev_dependencies %}
|
|
35
|
+
"{{ dep }}": "latest",
|
|
36
|
+
{%- endfor %}
|
|
37
|
+
{%- if use_tailwind %}
|
|
38
|
+
"@tailwindcss/vite": "^4.1.17",
|
|
39
|
+
"tailwindcss": "^4.1.17",
|
|
40
|
+
{%- endif %}
|
|
41
|
+
{%- if generate_client %}
|
|
42
|
+
"@hey-api/openapi-ts": "^0.88.0",
|
|
43
|
+
{%- endif %}
|
|
44
|
+
"litestar-vite-plugin": "latest",
|
|
45
|
+
"vite": "^7.2.6"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.app {
|
|
17
|
+
max-width: 1280px;
|
|
18
|
+
margin: 0 auto;
|
|
19
|
+
padding: 2rem;
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.message {
|
|
24
|
+
color: #646cff;
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.back-link {
|
|
29
|
+
color: #646cff;
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.back-link:hover {
|
|
34
|
+
text-decoration: underline;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.user-list {
|
|
38
|
+
list-style: none;
|
|
39
|
+
padding: 0;
|
|
40
|
+
margin-top: 2rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.user-item {
|
|
44
|
+
padding: 1rem;
|
|
45
|
+
margin: 0.5rem 0;
|
|
46
|
+
background: #1a1a1a;
|
|
47
|
+
border-radius: 8px;
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.user-item strong {
|
|
53
|
+
color: #fff;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.user-item span {
|
|
57
|
+
color: #888;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (prefers-color-scheme: light) {
|
|
61
|
+
:root {
|
|
62
|
+
color: #213547;
|
|
63
|
+
background-color: #ffffff;
|
|
64
|
+
}
|
|
65
|
+
.user-item {
|
|
66
|
+
background-color: #f9f9f9;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { createInertiaApp } from "@inertiajs/react";
|
|
4
|
+
import { resolvePageComponent } from "litestar-vite-plugin/inertia-helpers";
|
|
5
|
+
import "./App.css";
|
|
6
|
+
|
|
7
|
+
createInertiaApp({
|
|
8
|
+
resolve: (name) =>
|
|
9
|
+
resolvePageComponent(`./pages/${name}.tsx`, import.meta.glob("./pages/**/*.tsx")),
|
|
10
|
+
setup({ el, App, props }) {
|
|
11
|
+
createRoot(el).render(
|
|
12
|
+
<StrictMode>
|
|
13
|
+
<App {...props} />
|
|
14
|
+
</StrictMode>
|
|
15
|
+
);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Head } from "@inertiajs/react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
message?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default function Home({ message }: Props) {
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Head title="Home" />
|
|
11
|
+
<div className="app">
|
|
12
|
+
<h1>{{ project_name }}</h1>
|
|
13
|
+
<p>React + Inertia.js + Litestar</p>
|
|
14
|
+
{message && <p className="message">{message}</p>}
|
|
15
|
+
</div>
|
|
16
|
+
</>
|
|
17
|
+
);
|
|
18
|
+
}
|