init: run and move to app router

main
Carsten Kragelund 2023-07-28 13:21:54 +02:00
parent f8ab614290
commit 01fee29a39
Signed by: nyx
GPG Key ID: CADDADEEC9F753C0
6 changed files with 2789 additions and 66 deletions

2696
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,21 @@
import { Metadata } from "next";
export const metadata: Metadata = {
title: "Rapid App with NextJS App-Router",
description:
"Rapid App with NextJS App Router (React TypeScript + Rust Api Routes)",
};
export default function Layout({
// Layouts must accept a children prop.
// This will be populated with nested layouts or pages
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}

@ -0,0 +1,18 @@
import { Welcome, createBoltClient } from "@rapid-web/react";
import { routes, Handlers } from "../pages/api/bindings";
const bolt = createBoltClient<Handlers, typeof routes>(routes, {
transport: "http://localhost:8080",
});
export default async function Home() {
const { data: title } = await bolt("hello").get(routes.hello);
return (
<main>
<Welcome>
<p className="mt-4">{title}</p>
</Welcome>
</main>
);
}

@ -2,28 +2,28 @@
export interface Handlers {
queries: {
index: {
output: any;
type: 'query';
isDynamic: false;
};
"index": {
output: any
type: 'query'
isDynamic: false
},
hello: {
output: string;
type: 'query';
isDynamic: false;
};
};
mutations: {};
"hello": {
output: string
type: 'query'
isDynamic: false
},
},
mutations: {},
}
export const routes = {
index: {
"index": {
url: '/',
type: 'query',
},
hello: {
"hello": {
url: '/hello',
type: 'query',
},
} as const;
} as const

@ -1,30 +0,0 @@
import { Welcome, createBoltClient } from '@rapid-web/react';
import { routes, Handlers } from './api/bindings';
interface Props {
title: string;
}
export const bolt = createBoltClient<Handlers, typeof routes>(routes, {
transport: 'http://localhost:8080',
});
export default function Home({ title }: Props) {
return (
<main>
<Welcome>
<p className='mt-4'>{title}</p>
</Welcome>
</main>
);
}
export async function getServerSideProps() {
const req = await bolt('hello').get(routes.hello);
return {
props: {
title: req.data,
},
};
}

@ -1,23 +1,41 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": [
"./*"
]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}