feat: create base tuono example

This commit is contained in:
Valerio Ageno
2024-05-26 19:05:19 +02:00
parent 0780a6ec79
commit c12739d526
14 changed files with 125 additions and 2 deletions
+13
View File
@@ -0,0 +1,13 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.tuono
out
target
+17
View File
@@ -0,0 +1,17 @@
[package]
name = "tuono"
version = "0.0.1"
edition = "2021"
[[bin]]
name = "tuono"
path = ".tuono/main.rs"
[dependencies]
axum = {version = "0.7.5", features = ["json"]}
tokio = { version = "1.37.0", features = ["full"] }
tower-http = {version = "0.5.2", features = ["fs"]}
serde = { version = "1.0.202", features = ["derive"] }
tuono_lib = "0.0.6"
serde_json = "1.0"
+2
View File
@@ -1 +1,3 @@
# TODO: Basic Tuono app
+14
View File
@@ -0,0 +1,14 @@
{
"name": "tuono",
"version": "0.0.1",
"dependencies": {
"react": "18.3.1",
"react-dom": "18.3.1",
"tuono": "workspace:*"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"typescript": "^5.4.5"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+3
View File
@@ -0,0 +1,3 @@
export default function Button(): JSX.Element {
return <button>Button</button>
}
+16
View File
@@ -0,0 +1,16 @@
import type { ReactNode } from 'react'
import { Link } from 'tuono'
interface RootRouteProps {
children: ReactNode
}
export default function RootRoute({ children }: RootRouteProps): JSX.Element {
return (
<>
<nav>
Navbar: <Link>About</Link>
</nav>
<main>{children}</main>
</>
)
}
+3
View File
@@ -0,0 +1,3 @@
export default function AboutPage(): JSX.Element {
return <h1>About page</h1>
}
+16
View File
@@ -0,0 +1,16 @@
use serde::Serialize;
use tuono_lib::{Request, Response};
#[derive(Serialize)]
struct MyResponse<'a> {
title: &'a str,
subtitle: &'a str,
}
#[tuono_lib::handler]
fn get_server_side_props(req: &Request) -> Response {
Response::Props(Box::new(MyResponse {
title: "title",
subtitle: "subtitle",
}))
}
+3
View File
@@ -0,0 +1,3 @@
export default function IndexPage(): JSX.Element {
return <h1>Index Page</h1>
}
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
+11
View File
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["vite.config.ts"]
}