create-bhvr
Version:
Create a new bhvr project
8 lines (7 loc) • 6.47 kB
TypeScript
import type { TemplateInfo } from "@/types";
export declare const TEMPLATES: Record<string, TemplateInfo>;
export declare const honoRpcTemplate = "import { Hono } from \"hono\";\nimport { cors } from \"hono/cors\";\nimport type { ApiResponse } from \"shared/dist\";\n\nexport const app = new Hono()\n\n.use(cors())\n\n.get(\"/\", (c) => {\n\treturn c.text(\"Hello Hono!\");\n})\n\n.get(\"/hello\", async (c) => {\n\tconst data: ApiResponse = {\n\t\tmessage: \"Hello BHVR!\",\n\t\tsuccess: true,\n\t};\n\n\treturn c.json(data, { status: 200 });\n});\n\nexport default app;";
export declare const honoClientTemplate = "import { hc } from \"hono/client\";\nimport type { app } from \"./index\";\n\nexport type AppType = typeof app;\nexport type Client = ReturnType<typeof hc<AppType>>;\n\nexport const hcWithType = (...args: Parameters<typeof hc>): Client =>\n hc<AppType>(...args);";
export declare const tailwindTemplate = "import { useState } from 'react'\nimport beaver from './assets/beaver.svg'\nimport { hcWithType } from 'server/dist/client'\n\nconst SERVER_URL = import.meta.env.VITE_SERVER_URL || \"http://localhost:3000\"\n\ntype ResponseType = Awaited<ReturnType<typeof client.hello.$get>>;\n\nconst client = hcWithType(SERVER_URL);\n\nfunction App() {\n const [data, setData] = useState<Awaited<ReturnType<ResponseType[\"json\"]>> | undefined>()\n\n async function sendRequest() {\n try {\n const res = await client.hello.$get()\n if (!res.ok) {\n console.log(\"Error fetching data\")\n return\n }\n const data = await res.json()\n setData(data)\n } catch (error) {\n console.log(error)\n }\n }\n\n return (\n <div className=\"max-w-xl mx-auto flex flex-col gap-6 items-center justify-center min-h-screen\">\n <a href=\"https://github.com/stevedylandev/bhvr\" target=\"_blank\">\n <img\n src={beaver}\n className=\"w-16 h-16 cursor-pointer\"\n alt=\"beaver logo\"\n />\n </a>\n <h1 className=\"text-5xl font-black\">bhvr</h1>\n <h2 className=\"text-2xl font-bold\">Bun + Hono + Vite + React</h2>\n <p>A typesafe fullstack monorepo</p>\n <div className='flex items-center gap-4'>\n <button\n onClick={sendRequest}\n className=\"bg-black text-white px-2.5 py-1.5 rounded-md\"\n >\n Call API\n </button>\n <a target='_blank' href=\"https://bhvr.dev\" className='border-1 border-black text-black px-2.5 py-1.5 rounded-md'>\n Docs\n </a>\n </div>\n {data && (\n <pre className=\"bg-gray-100 p-4 rounded-md\">\n <code>\n Message: {data.message} <br />\n Success: {data.success.toString()}\n </code>\n </pre>\n )}\n </div>\n )\n}\n\nexport default App";
export declare const shadcnTemplate = "import { useState } from 'react'\nimport beaver from './assets/beaver.svg'\nimport { Button } from './components/ui/button'\nimport { hcWithType } from 'server/dist/client'\n\nconst SERVER_URL = import.meta.env.VITE_SERVER_URL || \"http://localhost:3000\"\n\nconst client = hcWithType(SERVER_URL);\n\ntype ResponseType = Awaited<ReturnType<typeof client.hello.$get>>;\n\nfunction App() {\n const [data, setData] = useState<Awaited<ReturnType<ResponseType[\"json\"]>> | undefined>()\n\n async function sendRequest() {\n try {\n const res = await client.hello.$get()\n if (!res.ok) {\n console.log(\"Error fetching data\")\n return\n }\n const data = await res.json()\n setData(data)\n } catch (error) {\n console.log(error)\n }\n }\n\n return (\n <div className=\"max-w-xl mx-auto flex flex-col gap-6 items-center justify-center min-h-screen\">\n <a href=\"https://github.com/stevedylandev/bhvr\" target=\"_blank\">\n <img\n src={beaver}\n className=\"w-16 h-16 cursor-pointer\"\n alt=\"beaver logo\"\n />\n </a>\n <h1 className=\"text-5xl font-black\">bhvr</h1>\n <h2 className=\"text-2xl font-bold\">Bun + Hono + Vite + React</h2>\n <p>A typesafe fullstack monorepo</p>\n <div className='flex items-center gap-4'>\n <Button\n onClick={sendRequest}\n >\n Call API\n </Button>\n <Button\n variant='secondary'\n asChild\n >\n <a target='_blank' href=\"https://bhvr.dev\">\n Docs\n </a>\n </Button>\n </div>\n {data && (\n <pre className=\"bg-gray-100 p-4 rounded-md\">\n <code>\n Message: {data.message} <br />\n Success: {data.success.toString()}\n </code>\n </pre>\n )}\n </div>\n )\n}\n\nexport default App";
export declare const defaultTemplate = "import { useState } from 'react'\nimport beaver from './assets/beaver.svg'\nimport { hcWithType } from 'server/dist/client'\nimport './App.css'\n\nconst SERVER_URL = import.meta.env.VITE_SERVER_URL || \"http://localhost:3000\"\n\nconst client = hcWithType(SERVER_URL);\n\ntype ResponseType = Awaited<ReturnType<typeof client.hello.$get>>;\n\nfunction App() {\n const [data, setData] = useState<Awaited<ReturnType<ResponseType[\"json\"]>> | undefined>()\n\n async function sendRequest() {\n try {\n const res = await client.hello.$get()\n if (!res.ok) {\n console.log(\"Error fetching data\")\n return\n }\n const data = await res.json()\n setData(data)\n } catch (error) {\n console.log(error)\n }\n }\n\n return (\n <>\n <div>\n <a href=\"https://github.com/stevedylandev/bhvr\" target=\"_blank\">\n <img src={beaver} className=\"logo\" alt=\"beaver logo\" />\n </a>\n </div>\n <h1>bhvr</h1>\n <h2>Bun + Hono + Vite + React</h2>\n <p>A typesafe fullstack monorepo</p>\n <div className=\"card\">\n <div className='button-container'>\n <button onClick={sendRequest}>\n Call API\n </button>\n <a className='docs-link' target='_blank' href=\"https://bhvr.dev\">Docs</a>\n </div>\n {data && (\n <pre className='response'>\n <code>\n Message: {data.message} <br />\n Success: {data.success.toString()}\n </code>\n </pre>\n )}\n </div>\n </>\n )\n}\n\nexport default App";