1 Commits

Author SHA1 Message Date
a8b1c311a4 chore(deps): update nextjs monorepo to v15
Some checks failed
renovate/artifacts Artifact file update failure
2024-12-20 01:25:43 +00:00
36 changed files with 2931 additions and 388 deletions

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-empty-plan.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-empty-plan.git"
vars:
service: "%%name%%"
@@ -12,5 +12,5 @@ please:
repository: "%%name%%"
branch: main
settings:
api_url: https://git.kjuulh.io
api_url: https://git.front.kjuulh.io

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-infrastructure-plan.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-infrastructure-plan.git"
vars:
service: "%%name%%"
@@ -13,7 +13,7 @@ vars:
deployment:
registry: git@git.kjuulh.io:kjuulh/clank-clusters
registry: git@git.front.kjuulh.io:kjuulh/clank-clusters
env:
prod:
clusters:

2667
cuddle-leptos/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,25 +9,25 @@ lto = true
opt-level = 'z'
[workspace.dependencies]
leptos = { version = "0.8.0", features = ["nightly"] }
leptos_meta = { version = "0.8.0" }
leptos_router = { version = "0.8.0", features = ["nightly"] }
leptos_axum = { version = "0.8.0" }
server_fn = { version = "0.8.0", features = [] }
leptos = { version = "0.6", features = ["nightly"] }
leptos_meta = { version = "0.6", features = ["nightly"] }
leptos_router = { version = "0.6", features = ["nightly"] }
leptos_axum = { version = "0.6" }
server_fn = { version = "0.6", features = [] }
serde = { version = "1", features = ["derive"] }
axum = "0.8"
axum = "0.7"
cfg-if = "1"
console_error_panic_hook = "0.1.7"
console_log = "1"
http = "1"
log = "0.4.21"
simple_logger = "5.0.0"
thiserror = "2"
thiserror = "1"
tokio = { version = "1.37.0", features = ["full"] }
tower = { version = "0.5.0", features = ["full"] }
tower-http = { version = "0.6", features = ["full"] }
wasm-bindgen = "=0.2.99"
tower-http = { version = "0.5", features = ["full"] }
wasm-bindgen = "=0.2.93"
# See https://github.com/akesson/cargo-leptos for documentation of all the parameters.
@@ -65,9 +65,6 @@ site-addr = "127.0.0.1:3000"
# The port to use for automatic reload monitoring
reload-port = 3001
# Optional, Activates the tailwind build
tailwind-input-file = "style/tailwind.css"
# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
# [Windows] for non-WSL use "npx.cmd playwright test"
# This binary name can be checked in Powershell with Get-Command npx

View File

@@ -16,4 +16,3 @@ tokio.workspace = true
tower.workspace = true
tower-http.workspace = true
log.workspace = true
dotenvy = "0.15.7"

View File

@@ -0,0 +1,44 @@
use app::App;
use axum::response::Response as AxumResponse;
use axum::{
body::Body,
extract::State,
http::{Request, Response, StatusCode, Uri},
response::IntoResponse,
};
use leptos::*;
use tower::ServiceExt;
use tower_http::services::ServeDir;
pub async fn file_and_error_handler(
uri: Uri,
State(options): State<LeptosOptions>,
req: Request<Body>,
) -> AxumResponse {
let root = options.site_root.clone();
let res = get_static_file(uri.clone(), &root).await.unwrap();
if res.status() == StatusCode::OK {
res.into_response()
} else {
let handler =
leptos_axum::render_app_to_stream(options.to_owned(), move || view! { <App/> });
handler(req).await.into_response()
}
}
async fn get_static_file(uri: Uri, root: &str) -> Result<Response<Body>, (StatusCode, String)> {
let req = Request::builder()
.uri(uri.clone())
.body(Body::empty())
.unwrap();
// `ServeDir` implements `tower::Service` so we can call it with `tower::ServiceExt::oneshot`
// This path is relative to the cargo root
match ServeDir::new(root).oneshot(req).await {
Ok(res) => Ok(res.map(Body::new)),
Err(err) => Err((
StatusCode::INTERNAL_SERVER_ERROR,
format!("Something went wrong: {err}"),
)),
}
}

View File

@@ -1,14 +1,14 @@
use app::*;
use axum::Router;
use leptos::prelude::*;
use fileserv::file_and_error_handler;
use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use state::State;
use tokio::signal;
pub mod fileserv;
#[tokio::main]
async fn main() {
let _ = dotenvy::dotenv();
simple_logger::init_with_level(log::Level::Debug).expect("couldn't initialize logging");
// Setting get_configuration(None) means we'll be using cargo-leptos's env values
@@ -16,31 +16,15 @@ async fn main() {
// <https://github.com/leptos-rs/start-axum#executing-a-server-on-a-remote-machine-without-the-toolchain>
// Alternately a file can be specified such as Some("Cargo.toml")
// The file would need to be included with the executable when moved to deployment
let conf = get_configuration(None).unwrap();
let conf = get_configuration(None).await.unwrap();
let leptos_options = conf.leptos_options;
let state = State {};
let addr = leptos_options.site_addr;
let routes = generate_route_list(App);
// build our application with a route
let app = Router::new()
.leptos_routes_with_context(
&leptos_options,
routes,
{
let state = state.clone();
move || {
provide_context(state.clone());
}
},
{
let leptos_options = leptos_options.clone();
move || shell(leptos_options.clone())
},
)
.fallback(leptos_axum::file_and_error_handler(shell))
.leptos_routes(&leptos_options, routes, App)
.fallback(file_and_error_handler)
.with_state(leptos_options);
// run our app with hyper

View File

@@ -17,30 +17,9 @@ serde.workspace = true
http.workspace = true
cfg-if.workspace = true
thiserror.workspace = true
cynic = { version = "3.9.1", optional = true, features = [
"http-reqwest",
"reqwest",
"serde_json",
] }
reqwest = { version = "0.12.11", optional = true, features = ["json"] }
axum = { workspace = true, optional = true, features = ["macros"] }
serde_json = { version = "1.0.134", optional = true }
[features]
default = []
hydrate = ["leptos/hydrate"]
ssr = [
"leptos/ssr",
"leptos_meta/ssr",
"leptos_router/ssr",
"dep:leptos_axum",
"dep:tokio",
"dep:cynic",
"dep:reqwest",
"dep:axum",
"dep:serde_json",
]
cynic = ["dep:cynic"]
reqwest = ["dep:reqwest"]
axum = ["dep:axum"]
serde_json = ["dep:serde_json"]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
ssr = ["leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", "dep:leptos_axum", "dep:tokio"]

View File

@@ -1,6 +1,6 @@
use cfg_if::cfg_if;
use http::status::StatusCode;
use leptos::prelude::*;
use leptos::*;
use thiserror::Error;
#[cfg(feature = "ssr")]
@@ -28,7 +28,7 @@ pub fn ErrorTemplate(
#[prop(optional)] errors: Option<RwSignal<Errors>>,
) -> impl IntoView {
let errors = match outside_errors {
Some(e) => RwSignal::new(e),
Some(e) => create_rw_signal(e),
None => match errors {
Some(e) => e,
None => panic!("No Errors found and we expected errors!"),

View File

@@ -1,32 +1,12 @@
use crate::error_template::{AppError, ErrorTemplate};
use leptos::prelude::*;
use leptos::*;
use leptos_meta::*;
use leptos_router::{components::*, StaticSegment};
use leptos_router::*;
use serde::{Deserialize, Serialize};
pub mod error_template;
#[cfg(feature = "ssr")]
pub mod state;
pub fn shell(options: LeptosOptions) -> impl IntoView {
view! {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<AutoReload options=options.clone() />
<HydrationScripts options />
<MetaTags />
</head>
<body>
<App />
</body>
</html>
}
}
#[component]
pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
@@ -39,14 +19,14 @@ pub fn App() -> impl IntoView {
<Title text="%%name%%"/>
// content for this welcome page
<Router>
<main class="">
<Routes fallback=|| {
<Router fallback=|| {
let mut outside_errors = Errors::default();
outside_errors.insert_with_default_key(AppError::NotFound);
view! { <ErrorTemplate outside_errors/> }.into_view()
}>
<Route path=StaticSegment("") view=pages::home::HomePage />
<main>
<Routes>
<Route ssr=SsrMode::Async path="" view=HomePage/>
</Routes>
</main>
</Router>
@@ -54,8 +34,6 @@ pub fn App() -> impl IntoView {
}
#[component]
pub fn HomePage() -> impl IntoView {
view! {
<h1> "%%name%%" </h1>
}
fn HomePage() -> impl IntoView {
view! {<h1> Hello %%name%% </h1>}
}

View File

@@ -1,14 +0,0 @@
use axum::extract::FromRef;
use leptos::prelude::expect_context;
use server_fn::ServerFnError;
#[derive(FromRef, Clone)]
pub struct State {}
pub async fn get_state() -> Result<State, ServerFnError> {
let state = expect_context::<crate::state::State>();
let axum::extract::State(state): axum::extract::State<crate::state::State> =
leptos_axum::extract_with_state(&state).await?;
Ok(state)
}

View File

@@ -1,10 +1,12 @@
#[wasm_bindgen::prelude::wasm_bindgen]
pub fn hydrate() {
use app::*;
use leptos::*;
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
pub fn hydrate() {
// initializes logging using the `log` crate
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
leptos::mount::hydrate_body(App);
leptos::mount_to_body(App);
}

View File

@@ -1,31 +1,21 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-leptos-plan.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-leptos-plan.git"
vars:
service: "%%name%%"
registry: kasperhermansen
ingress:
- external: "true"
- internal: "true"
clusters:
clank-prod:
replicas: "3"
namespace: prod
cuddle/clusters:
dev:
deployment:
registry: git@git.front.kjuulh.io:kjuulh/clank-clusters
env:
service.host: "0.0.0.0:3000"
content.url: https://content.front.kjuulh.io/graphql
content.base.url: https://content.front.kjuulh.io
content.token:
vault: true
prod:
env:
service.host: "0.0.0.0:3000"
content.url: https://content.front.kjuulh.io/graphql
content.base.url: https://content.front.kjuulh.io
content.token:
vault: true
clusters:
- clank-prod
scripts:
generate_graphql:
type: shell

View File

@@ -13,96 +13,61 @@
}
},
"node_modules/@playwright/test": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.57.0.tgz",
"integrity": "sha512-6TyEnHgd6SArQO8UO2OMTxshln3QMWBtPGrOCgs3wVEmQmwyuNtB10IZMfmYDE0riwNR1cu4q+pPcxMVtaG3TA==",
"version": "1.28.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.28.0.tgz",
"integrity": "sha512-vrHs5DFTPwYox5SGKq/7TDn/S4q6RA1zArd7uhO6EyP9hj3XgZBBM12ktMbnDQNxh/fL1IUKsTNLxihmsU38lQ==",
"dev": true,
"dependencies": {
"playwright": "1.57.0"
"@types/node": "*",
"playwright-core": "1.28.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
"node": ">=14"
}
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/playwright": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.57.0.tgz",
"integrity": "sha512-ilYQj1s8sr2ppEJ2YVadYBN0Mb3mdo9J0wQ+UuDhzYqURwSoW4n1Xs5vs7ORwgDGmyEh33tRMeS8KhdkMoLXQw==",
"dev": true,
"dependencies": {
"playwright-core": "1.57.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
"node_modules/@types/node": {
"version": "18.11.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
"dev": true
},
"node_modules/playwright-core": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.57.0.tgz",
"integrity": "sha512-agTcKlMw/mjBWOnD6kFZttAAGHgi/Nw0CZ2o6JqWSbMlI219lAFLZZCyqByTsvVAJq5XA5H8cA6PrvBRpBWEuQ==",
"version": "1.28.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.28.0.tgz",
"integrity": "sha512-nJLknd28kPBiCNTbqpu6Wmkrh63OEqJSFw9xOfL9qxfNwody7h6/L3O2dZoWQ6Oxcm0VOHjWmGiCUGkc0X3VZA==",
"dev": true,
"bin": {
"playwright-core": "cli.js"
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
"node": ">=14"
}
}
},
"dependencies": {
"@playwright/test": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.57.0.tgz",
"integrity": "sha512-6TyEnHgd6SArQO8UO2OMTxshln3QMWBtPGrOCgs3wVEmQmwyuNtB10IZMfmYDE0riwNR1cu4q+pPcxMVtaG3TA==",
"version": "1.28.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.28.0.tgz",
"integrity": "sha512-vrHs5DFTPwYox5SGKq/7TDn/S4q6RA1zArd7uhO6EyP9hj3XgZBBM12ktMbnDQNxh/fL1IUKsTNLxihmsU38lQ==",
"dev": true,
"requires": {
"playwright": "1.57.0"
"@types/node": "*",
"playwright-core": "1.28.0"
}
},
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
"playwright": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.57.0.tgz",
"integrity": "sha512-ilYQj1s8sr2ppEJ2YVadYBN0Mb3mdo9J0wQ+UuDhzYqURwSoW4n1Xs5vs7ORwgDGmyEh33tRMeS8KhdkMoLXQw==",
"dev": true,
"requires": {
"fsevents": "2.3.2",
"playwright-core": "1.57.0"
}
"@types/node": {
"version": "18.11.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
"dev": true
},
"playwright-core": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.57.0.tgz",
"integrity": "sha512-agTcKlMw/mjBWOnD6kFZttAAGHgi/Nw0CZ2o6JqWSbMlI219lAFLZZCyqByTsvVAJq5XA5H8cA6PrvBRpBWEuQ==",
"version": "1.28.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.28.0.tgz",
"integrity": "sha512-nJLknd28kPBiCNTbqpu6Wmkrh63OEqJSFw9xOfL9qxfNwody7h6/L3O2dZoWQ6Oxcm0VOHjWmGiCUGkc0X3VZA==",
"dev": true
}
}

View File

@@ -1,12 +0,0 @@
max_width = 100 # Maximum width of each line
tab_spaces = 4 # Number of spaces per tab
indentation_style = "Auto" # "Tabs", "Spaces" or "Auto"
newline_style = "Auto" # "Unix", "Windows" or "Auto"
attr_value_brace_style = "WhenRequired" # "Always", "AlwaysUnlessLit", "WhenRequired" or "Preserve"
macro_names = ["leptos::view", "view"] # Macro names which will be formatted
closing_tag_style = "Preserve" # "Preserve", "SelfClosing" or "NonSelfClosing"
# Attribute values can be formatted by custom formatters
# Every attribute name may only select one formatter (this might change later on)
[attr_values]
class = "Tailwind" # "Tailwind" is the only attribute value formatter available for now

View File

@@ -1,2 +0,0 @@
[rustfmt]
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]

View File

@@ -1 +0,0 @@
edition = "2021"

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env zsh
set -e
graphql-schema download --endpoint http://localhost:1337/graphql --output-file crates/app/graphql/content-schema.graphql

View File

@@ -6,6 +6,6 @@
body {
font-family: var(--main-font);
//background-color: var(--main-background);
//color: var(--main-color);
background-color: var(--main-background);
color: var(--main-color);
}

View File

@@ -1,7 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
.page-center {
@apply max-w-4xl mx-auto px-4 h-full;
}

View File

@@ -1,13 +0,0 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: {
files: ["*.html", "./crates/app/src/**/*.rs"],
transform: {
rs: (content) => content.replace(/(?:^|\s)class:/g, ' '),
},
},
theme: {
extend: {},
},
plugins: [],
}

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-node-service-plan.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-node-service-plan.git"
vars:
service: "%%name%%"
@@ -13,7 +13,7 @@ vars:
deployment:
registry: git@git.kjuulh.io:kjuulh/clank-clusters
registry: git@git.front.kjuulh.io:kjuulh/clank-clusters
env:
prod:
clusters:

View File

@@ -9,19 +9,19 @@
"lint": "next lint"
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"next": "14.1.4"
"react": "^18",
"react-dom": "^18",
"next": "15.1.2"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^22.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"postcss": "^8",
"tailwindcss": "^4.0.0",
"tailwindcss": "^3.3.0",
"eslint": "^8",
"eslint-config-next": "14.1.4"
"eslint-config-next": "15.1.2"
}
}

View File

@@ -474,7 +474,9 @@ ast-types-flow@^0.0.8:
integrity sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==
autoprefixer@^10.0.1:
version "10.4.21"
version "10.4.19"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.19.tgz#ad25a856e82ee9d7898c59583c1afeb3fa65f89f"
integrity sha512-BaENR2+zBZ8xXhM4pUaKUxlVdxZ0EZhjvbopwnXmxRUfqDmwSpC2lAi/QXvx7NRdPCo1WKEcEF6mV64si1z4Ew==
dependencies:
browserslist "^4.23.0"
caniuse-lite "^1.0.30001599"
@@ -2104,7 +2106,9 @@ postcss@8.4.31:
source-map-js "^1.0.2"
postcss@^8, postcss@^8.4.23:
version "8.5.6"
version "8.4.38"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.38.tgz#b387d533baf2054288e337066d81c6bee9db9e0e"
integrity sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==
dependencies:
nanoid "^3.3.7"
picocolors "^1.0.0"
@@ -2622,7 +2626,9 @@ typed-array-length@^1.0.6:
possible-typed-array-names "^1.0.0"
typescript@^5:
version "5.8.3"
version "5.4.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.4.tgz#eb2471e7b0a5f1377523700a21669dce30c2d952"
integrity sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==
unbox-primitive@^1.0.2:
version "1.0.2"

View File

@@ -14,6 +14,6 @@ dotenv.workspace = true
axum.workspace = true
serde = { version = "1.0.197", features = ["derive"] }
sqlx = { version = "0.8.0", features = ["runtime-tokio", "tls-rustls", "postgres", "uuid", "time"] }
sqlx = { version = "0.7.3", features = ["runtime-tokio", "tls-rustls", "postgres", "uuid", "time"] }
uuid = { version = "1.7.0", features = ["v4"] }
tower-http = { version = "0.6.0", features = ["cors", "trace"] }
tower-http = { version = "0.5.2", features = ["cors", "trace"] }

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-cli-plan.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-cli-plan.git"
vars:
service: "%%name%%"
@@ -12,6 +12,6 @@ please:
repository: "%%name%%"
branch: "main"
settings:
api_url: "https://git.kjuulh.io"
api_url: "https://git.front.kjuulh.io"
actions:
rust:

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-lib-plan.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-lib-plan.git"
vars:
service: "%%name%%"
@@ -12,6 +12,6 @@ please:
repository: "%%name%%"
branch: main
settings:
api_url: "https://git.kjuulh.io"
api_url: "https://git.front.kjuulh.io"
actions:
rust:

View File

@@ -8,11 +8,7 @@ resolver = "2"
anyhow = { version = "1" }
tokio = { version = "1", features = ["full"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3" }
tracing-subscriber = { version = "0.3.18" }
clap = { version = "4", features = ["derive", "env"] }
dotenv = { version = "0.15" }
axum = { version = "0.8" }
serde = { version = "1", features = ["derive"] }
uuid = { version = "1", features = ["v4"] }
tower-http = { version = "0.6", features = ["cors", "trace"] }
notmad = "0.8"
axum = { version = "0.7" }

View File

@@ -1,7 +1,7 @@
[package]
name = "%%name%%"
version = "0.1.0"
edition = "2024"
edition = "2021"
[dependencies]
anyhow.workspace = true
@@ -11,7 +11,7 @@ tracing-subscriber.workspace = true
clap.workspace = true
dotenv.workspace = true
axum.workspace = true
serde.workspace = true
uuid.workspace = true
tower-http.workspace = true
notmad.workspace = true
serde = { version = "1.0.197", features = ["derive"] }
uuid = { version = "1.7.0", features = ["v4"] }
tower-http = { version = "0.5.2", features = ["cors", "trace"] }

View File

@@ -1,36 +1,40 @@
mod state {
#[derive(Clone)]
pub struct State {}
use std::{net::SocketAddr, ops::Deref, sync::Arc};
impl State {
pub async fn new() -> anyhow::Result<Self> {
Ok(Self {})
}
}
}
pub use state::*;
pub mod cli {
use anyhow::Context;
use axum::extract::MatchedPath;
use axum::http::Request;
use axum::Router;
use axum::routing::get;
use clap::{Parser, Subcommand};
use crate::{State, cli::serve::ServeCommand};
mod serve {
use std::net::SocketAddr;
use axum::{Router, extract::MatchedPath, http::Request, routing::get};
use tower_http::trace::TraceLayer;
use crate::State;
#[derive(clap::Parser)]
pub struct ServeCommand {
#[arg(env = "SERVICE_HOST", long, default_value = "127.0.0.1:3000")]
host: SocketAddr,
#[derive(Parser)]
#[command(author, version, about, long_about = None, subcommand_required = true)]
struct Command {
#[command(subcommand)]
command: Option<Commands>,
}
impl ServeCommand {
pub async fn execute(&self, state: &State) -> anyhow::Result<()> {
#[derive(Subcommand)]
enum Commands {
Serve {
#[arg(env = "SERVICE_HOST", long, default_value = "127.0.0.1:3000")]
host: SocketAddr,
},
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
tracing_subscriber::fmt::init();
let cli = Command::parse();
if let Some(Commands::Serve { host }) = cli.command {
tracing::info!("Starting service");
let state = SharedState(Arc::new(State::new().await?));
let app = Router::new()
.route("/", get(root))
.with_state(state.clone())
@@ -52,50 +56,36 @@ pub mod cli {
}), // ...
);
tracing::info!("listening on {}", self.host);
let listener = tokio::net::TcpListener::bind(self.host).await.unwrap();
tracing::info!("listening on {}", host);
let listener = tokio::net::TcpListener::bind(host).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
Ok(())
}
}
async fn root() -> &'static str {
"Hello, nostore!"
"Hello, %%name%%!"
}
#[derive(Clone)]
pub struct SharedState(Arc<State>);
impl Deref for SharedState {
type Target = Arc<State>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[derive(Parser)]
#[command(author, version, about, long_about = None, subcommand_required = true)]
struct Command {
#[command(subcommand)]
command: Option<Commands>,
}
pub struct State {}
#[derive(Subcommand)]
enum Commands {
Serve(ServeCommand),
}
pub async fn execute() -> anyhow::Result<()> {
let cli = Command::parse();
let state = State::new().await?;
match cli.command.expect("a subcommand") {
Commands::Serve(cmd) => cmd.execute(&state).await,
}
impl State {
pub async fn new() -> anyhow::Result<Self> {
Ok(Self {})
}
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
tracing_subscriber::fmt::init();
cli::execute().await?;
Ok(())
}

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-service-plan.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-service-plan.git"
vars:
service: "%%name%%"

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
vars:
service: "%%name%%"

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
vars:
service: "%%name%%"
@@ -12,4 +12,4 @@ please:
repository: "%%name%%"
branch: "main"
settings:
api_url: "https://git.kjuulh.io"
api_url: "https://git.front.kjuulh.io"

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
vars:
service: "%%name%%"
@@ -12,4 +12,4 @@ please:
repository: "%%name%%"
branch: main
settings:
api_url: "https://git.kjuulh.io"
api_url: "https://git.front.kjuulh.io"

View File

@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
vars:
service: "%%name%%"