-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 82e987d
Showing
27 changed files
with
774 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Since the ".env" file is gitignored, you can use the ".env.example" file to | ||
# build a new ".env" file when you clone the repo. Keep this file up-to-date | ||
# when you add new variables to `.env`. | ||
|
||
# This file will be committed to version control, so make sure not to have any | ||
# secrets in it. If you are cloning this repo, create a copy of this file named | ||
# ".env" and populate it with your secrets. | ||
|
||
# When adding additional environment variables, the schema in "/src/env.mjs" | ||
# should be updated accordingly. | ||
|
||
# Drizzle | ||
# Get the Database URL from the "prisma" dropdown selector in PlanetScale. | ||
# Change the query params at the end of the URL to "?ssl={"rejectUnauthorized":true}" | ||
DATABASE_URL='mysql://YOUR_MYSQL_URL_HERE?ssl={"rejectUnauthorized":true}' | ||
|
||
# Example: | ||
# SERVERVAR="foo" | ||
# NEXT_PUBLIC_CLIENTVAR="bar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
const config = { | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: true, | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
extends: [ | ||
"next/core-web-vitals", | ||
"plugin:@typescript-eslint/recommended-type-checked", | ||
"plugin:@typescript-eslint/stylistic-type-checked", | ||
], | ||
rules: { | ||
// These opinionated rules are enabled in stylistic-type-checked above. | ||
// Feel free to reconfigure them to your own preference. | ||
"@typescript-eslint/array-type": "off", | ||
"@typescript-eslint/consistent-type-definitions": "off", | ||
|
||
"@typescript-eslint/consistent-type-imports": [ | ||
"warn", | ||
{ | ||
prefer: "type-imports", | ||
fixStyle: "inline-type-imports", | ||
}, | ||
], | ||
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], | ||
"@typescript-eslint/no-misused-promises": [ | ||
2, | ||
{ | ||
checksVoidReturn: { attributes: false }, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# database | ||
/prisma/db.sqlite | ||
/prisma/db.sqlite-journal | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
next-env.d.ts | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables | ||
.env | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Create T3 App | ||
|
||
This is a [T3 Stack](https://create.t3.gg/) project bootstrapped with `create-t3-app`. | ||
|
||
## What's next? How do I make an app with this? | ||
|
||
We try to keep this project as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary. | ||
|
||
If you are not familiar with the different technologies used in this project, please refer to the respective docs. If you still are in the wind, please join our [Discord](https://t3.gg/discord) and ask for help. | ||
|
||
- [Next.js](https://nextjs.org) | ||
- [NextAuth.js](https://next-auth.js.org) | ||
- [Prisma](https://prisma.io) | ||
- [Tailwind CSS](https://tailwindcss.com) | ||
- [tRPC](https://trpc.io) | ||
|
||
## Learn More | ||
|
||
To learn more about the [T3 Stack](https://create.t3.gg/), take a look at the following resources: | ||
|
||
- [Documentation](https://create.t3.gg/) | ||
- [Learn the T3 Stack](https://create.t3.gg/en/faq#what-learning-resources-are-currently-available) — Check out these awesome tutorials | ||
|
||
You can check out the [create-t3-app GitHub repository](https://github.com/t3-oss/create-t3-app) — your feedback and contributions are welcome! | ||
|
||
## How do I deploy this? | ||
|
||
Follow our deployment guides for [Vercel](https://create.t3.gg/en/deployment/vercel), [Netlify](https://create.t3.gg/en/deployment/netlify) and [Docker](https://create.t3.gg/en/deployment/docker) for more information. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { type Config } from "drizzle-kit"; | ||
|
||
import { env } from "~/env.mjs"; | ||
|
||
export default { | ||
schema: "./src/server/db/schema.ts", | ||
driver: "mysql2", | ||
dbCredentials: { | ||
connectionString: env.DATABASE_URL, | ||
}, | ||
tablesFilter: ["property-room_*"], | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful | ||
* for Docker builds. | ||
*/ | ||
await import("./src/env.mjs"); | ||
|
||
/** @type {import("next").NextConfig} */ | ||
const config = {}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "property-room", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "next build", | ||
"db:push": "dotenv drizzle-kit push:mysql", | ||
"db:studio": "dotenv drizzle-kit studio", | ||
"dev": "next dev", | ||
"lint": "next lint", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@planetscale/database": "^1.11.0", | ||
"@t3-oss/env-nextjs": "^0.7.0", | ||
"@tanstack/react-query": "^4.32.6", | ||
"@trpc/client": "^10.37.1", | ||
"@trpc/next": "^10.37.1", | ||
"@trpc/react-query": "^10.37.1", | ||
"@trpc/server": "^10.37.1", | ||
"drizzle-orm": "^0.28.5", | ||
"next": "^13.5.4", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"superjson": "^1.13.1", | ||
"zod": "^3.22.4" | ||
}, | ||
"devDependencies": { | ||
"@types/eslint": "^8.44.2", | ||
"@types/node": "^18.16.0", | ||
"@types/react": "^18.2.20", | ||
"@types/react-dom": "^18.2.7", | ||
"@typescript-eslint/eslint-plugin": "^6.3.0", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"autoprefixer": "^10.4.14", | ||
"dotenv-cli": "^7.3.0", | ||
"drizzle-kit": "^0.19.13", | ||
"eslint": "^8.47.0", | ||
"eslint-config-next": "^13.5.4", | ||
"mysql2": "^3.6.1", | ||
"postcss": "^8.4.27", | ||
"prettier": "^3.0.0", | ||
"prettier-plugin-tailwindcss": "^0.5.1", | ||
"tailwindcss": "^3.3.3", | ||
"typescript": "^5.1.6" | ||
}, | ||
"ct3aMetadata": { | ||
"initVersion": "7.22.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const config = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').options} */ | ||
const config = { | ||
plugins: ["prettier-plugin-tailwindcss"], | ||
}; | ||
|
||
export default config; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
import { useState } from "react"; | ||
|
||
import { api } from "~/trpc/react"; | ||
|
||
export function CreatePost() { | ||
const router = useRouter(); | ||
const [name, setName] = useState(""); | ||
|
||
const createPost = api.post.create.useMutation({ | ||
onSuccess: () => { | ||
router.refresh(); | ||
setName(""); | ||
}, | ||
}); | ||
|
||
return ( | ||
<form | ||
onSubmit={(e) => { | ||
e.preventDefault(); | ||
createPost.mutate({ name }); | ||
}} | ||
className="flex flex-col gap-2" | ||
> | ||
<input | ||
type="text" | ||
placeholder="Title" | ||
value={name} | ||
onChange={(e) => setName(e.target.value)} | ||
className="w-full rounded-full px-4 py-2 text-black" | ||
/> | ||
<button | ||
type="submit" | ||
className="rounded-full bg-white/10 px-10 py-3 font-semibold transition hover:bg-white/20" | ||
disabled={createPost.isLoading} | ||
> | ||
{createPost.isLoading ? "Submitting..." : "Submit"} | ||
</button> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; | ||
import { type NextRequest } from "next/server"; | ||
|
||
import { env } from "~/env.mjs"; | ||
import { appRouter } from "~/server/api/root"; | ||
import { createTRPCContext } from "~/server/api/trpc"; | ||
|
||
const handler = (req: NextRequest) => | ||
fetchRequestHandler({ | ||
endpoint: "/api/trpc", | ||
req, | ||
router: appRouter, | ||
createContext: () => createTRPCContext({ req }), | ||
onError: | ||
env.NODE_ENV === "development" | ||
? ({ path, error }) => { | ||
console.error( | ||
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}` | ||
); | ||
} | ||
: undefined, | ||
}); | ||
|
||
export { handler as GET, handler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import "~/styles/globals.css"; | ||
|
||
import { Inter } from "next/font/google"; | ||
import { headers } from "next/headers"; | ||
|
||
import { TRPCReactProvider } from "~/trpc/react"; | ||
|
||
const inter = Inter({ | ||
subsets: ["latin"], | ||
variable: "--font-sans", | ||
}); | ||
|
||
export const metadata = { | ||
title: "Create T3 App", | ||
description: "Generated by create-t3-app", | ||
icons: [{ rel: "icon", url: "/favicon.ico" }], | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body className={`font-sans ${inter.variable}`}> | ||
<TRPCReactProvider headers={headers()}>{children}</TRPCReactProvider> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Link from "next/link"; | ||
|
||
import { CreatePost } from "~/app/_components/create-post"; | ||
import { api } from "~/trpc/server"; | ||
|
||
export default async function Home() { | ||
const hello = await api.post.hello.query({ text: "from tRPC" }); | ||
|
||
return ( | ||
<main className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c] text-white"> | ||
<div className="container flex flex-col items-center justify-center gap-12 px-4 py-16 "> | ||
<h1 className="text-5xl font-extrabold tracking-tight sm:text-[5rem]"> | ||
Create <span className="text-[hsl(280,100%,70%)]">T3</span> App | ||
</h1> | ||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:gap-8"> | ||
<Link | ||
className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 hover:bg-white/20" | ||
href="https://create.t3.gg/en/usage/first-steps" | ||
target="_blank" | ||
> | ||
<h3 className="text-2xl font-bold">First Steps →</h3> | ||
<div className="text-lg"> | ||
Just the basics - Everything you need to know to set up your | ||
database and authentication. | ||
</div> | ||
</Link> | ||
<Link | ||
className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 hover:bg-white/20" | ||
href="https://create.t3.gg/en/introduction" | ||
target="_blank" | ||
> | ||
<h3 className="text-2xl font-bold">Documentation →</h3> | ||
<div className="text-lg"> | ||
Learn more about Create T3 App, the libraries it uses, and how to | ||
deploy it. | ||
</div> | ||
</Link> | ||
</div> | ||
<div className="flex flex-col items-center gap-2"> | ||
<p className="text-2xl text-white"> | ||
{hello ? hello.greeting : "Loading tRPC query..."} | ||
</p> | ||
</div> | ||
|
||
<CrudShowcase /> | ||
</div> | ||
</main> | ||
); | ||
} | ||
|
||
async function CrudShowcase() { | ||
const latestPost = await api.post.getLatest.query(); | ||
|
||
return ( | ||
<div className="w-full max-w-xs"> | ||
{latestPost ? ( | ||
<p className="truncate">Your most recent post: {latestPost.name}</p> | ||
) : ( | ||
<p>You have no posts yet.</p> | ||
)} | ||
|
||
<CreatePost /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.