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 { export interface Handlers {
queries: { queries: {
index: { "index": {
output: any; output: any
type: 'query'; type: 'query'
isDynamic: false; isDynamic: false
}; },
hello: { "hello": {
output: string; output: string
type: 'query'; type: 'query'
isDynamic: false; isDynamic: false
}; },
}; },
mutations: {}; mutations: {},
} }
export const routes = { export const routes = {
index: { "index": {
url: '/', url: '/',
type: 'query', type: 'query',
}, },
hello: { "hello": {
url: '/hello', url: '/hello',
type: 'query', 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,7 +1,11 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": ["dom", "dom.iterable", "esnext"], "lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
@ -15,9 +19,23 @@
"jsx": "preserve", "jsx": "preserve",
"incremental": true, "incremental": true,
"paths": { "paths": {
"@/*": ["./*"] "@/*": [
"./*"
]
},
"plugins": [
{
"name": "next"
} }
]
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "include": [
"exclude": ["node_modules"] "next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
} }