Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrastopoulos committed Feb 12, 2024
1 parent 423bacf commit 31a11d3
Show file tree
Hide file tree
Showing 61 changed files with 693 additions and 2,175 deletions.
16 changes: 4 additions & 12 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@
# If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets.

# The database URL is used to connect to your PlanetScale database.
DB_HOST='aws.connect.psdb.cloud'
DB_NAME='YOUR_DB_NAME'
DB_USERNAME=''
DB_PASSWORD='pscale_pw_'
DATABASE_URL=''

# You can generate the secret via 'openssl rand -base64 32' on Unix
# @see https://next-auth.js.org/configuration/options#secret
AUTH_SECRET='supersecret'

# Preconfigured Discord OAuth provider, works out-of-the-box
# @see https://next-auth.js.org/providers/discord
AUTH_DISCORD_ID=''
AUTH_DISCORD_SECRET=''
# Configure auth provider
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=''
CLERK_SECRET_KEY=''
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"extends": ["config:base"],
"packageRules": [
{
"matchPackagePatterns": ["^@acme/"],
"matchPackagePatterns": ["^@scottylabs/"],
"enabled": false
}
],
Expand Down
7 changes: 0 additions & 7 deletions apps/auth-proxy/.env.example

This file was deleted.

16 changes: 0 additions & 16 deletions apps/auth-proxy/README.md

This file was deleted.

35 changes: 0 additions & 35 deletions apps/auth-proxy/package.json

This file was deleted.

17 changes: 0 additions & 17 deletions apps/auth-proxy/routes/[...auth].ts

This file was deleted.

4 changes: 0 additions & 4 deletions apps/auth-proxy/tsconfig.json

This file was deleted.

18 changes: 9 additions & 9 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@acme/expo",
"name": "@scottylabs/expo",
"version": "0.1.0",
"private": true,
"main": "expo-router/entry",
Expand Down Expand Up @@ -39,11 +39,11 @@
"superjson": "2.2.1"
},
"devDependencies": {
"@acme/api": "workspace:^0.1.0",
"@acme/eslint-config": "workspace:^0.2.0",
"@acme/prettier-config": "workspace:^0.1.0",
"@acme/tailwind-config": "workspace:^0.1.0",
"@acme/tsconfig": "workspace:^0.1.0",
"@scottylabs/api": "workspace:^0.1.0",
"@scottylabs/eslint-config": "workspace:^0.2.0",
"@scottylabs/prettier-config": "workspace:^0.1.0",
"@scottylabs/tailwind-config": "workspace:^0.1.0",
"@scottylabs/tsconfig": "workspace:^0.1.0",
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/runtime": "^7.23.9",
Expand All @@ -57,12 +57,12 @@
"eslintConfig": {
"root": true,
"extends": [
"@acme/eslint-config/base",
"@acme/eslint-config/react"
"@scottylabs/eslint-config/base",
"@scottylabs/eslint-config/react"
],
"ignorePatterns": [
"expo-plugins/**"
]
},
"prettier": "@acme/prettier-config"
"prettier": "@scottylabs/prettier-config"
}
5 changes: 2 additions & 3 deletions apps/expo/src/utils/api.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import type { AppRouter } from "@scottylabs/api";
import { useState } from "react";
import Constants from "expo-constants";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { httpBatchLink, loggerLink } from "@trpc/client";
import { createTRPCReact } from "@trpc/react-query";
import superjson from "superjson";

import type { AppRouter } from "@acme/api";

/**
* A set of typesafe hooks for consuming your API.
*/
export const api = createTRPCReact<AppRouter>();
export { type RouterInputs, type RouterOutputs } from "@acme/api";
export { type RouterInputs, type RouterOutputs } from "@scottylabs/api";

/**
* Extend this function when going to production by
Expand Down
3 changes: 1 addition & 2 deletions apps/expo/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { Config } from "tailwindcss";
import baseConfig from "@scottylabs/tailwind-config/native";
// @ts-expect-error - no types
import nativewind from "nativewind/preset";

import baseConfig from "@acme/tailwind-config/native";

export default {
content: ["./src/**/*.{ts,tsx}"],
presets: [baseConfig, nativewind],
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["@acme/tsconfig/base.json"],
"extends": ["@scottylabs/tsconfig/base.json"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
Expand Down
10 changes: 4 additions & 6 deletions apps/nextjs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ const jiti = _jiti(new URL(import.meta.url).pathname);

// Import env files to validate at build time. Use jiti so we can load .ts files in here.
jiti("./src/env");
jiti("@acme/auth/env");

/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,

/** Enables hot reloading for local packages without a build step */
transpilePackages: [
"@acme/api",
"@acme/auth",
"@acme/db",
"@acme/ui",
"@acme/validators",
"@scottylabs/api",
"@scottylabs/db",
"@scottylabs/ui",
"@scottylabs/validators",
],

/** We already do linting and typechecking as separate tasks in CI */
Expand Down
28 changes: 14 additions & 14 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@acme/nextjs",
"name": "@scottylabs/nextjs",
"version": "0.1.0",
"private": true,
"type": "module",
Expand All @@ -14,11 +14,11 @@
"with-env": "dotenv -e ../../.env --"
},
"dependencies": {
"@acme/api": "workspace:^0.1.0",
"@acme/auth": "workspace:^0.1.0",
"@acme/db": "workspace:^0.1.0",
"@acme/ui": "workspace:^0.1.0",
"@acme/validators": "workspace:^0.1.0",
"@clerk/nextjs": "^4.29.7",
"@scottylabs/api": "workspace:^0.1.0",
"@scottylabs/db": "workspace:^0.1.0",
"@scottylabs/ui": "workspace:^0.1.0",
"@scottylabs/validators": "workspace:^0.1.0",
"@t3-oss/env-nextjs": "^0.9.2",
"@tanstack/react-query": "^5.18.1",
"@trpc/client": "11.0.0-next-beta.264",
Expand All @@ -32,10 +32,10 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@acme/eslint-config": "workspace:^0.2.0",
"@acme/prettier-config": "workspace:^0.1.0",
"@acme/tailwind-config": "workspace:^0.1.0",
"@acme/tsconfig": "workspace:^0.1.0",
"@scottylabs/eslint-config": "workspace:^0.2.0",
"@scottylabs/prettier-config": "workspace:^0.1.0",
"@scottylabs/tailwind-config": "workspace:^0.1.0",
"@scottylabs/tsconfig": "workspace:^0.1.0",
"@types/node": "^20.11.13",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
Expand All @@ -49,10 +49,10 @@
"eslintConfig": {
"root": true,
"extends": [
"@acme/eslint-config/base",
"@acme/eslint-config/nextjs",
"@acme/eslint-config/react"
"@scottylabs/eslint-config/base",
"@scottylabs/eslint-config/nextjs",
"@scottylabs/eslint-config/react"
]
},
"prettier": "@acme/prettier-config"
"prettier": "@scottylabs/prettier-config"
}
39 changes: 3 additions & 36 deletions apps/nextjs/src/app/_components/auth-showcase.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
import { auth, signIn, signOut } from "@acme/auth";
import { Button } from "@acme/ui/button";
import { UserButton } from "@clerk/nextjs";

export async function AuthShowcase() {
const session = await auth();

if (!session) {
return (
<form>
<Button
size="lg"
formAction={async () => {
"use server";
await signIn("discord");
}}
>
Sign in with Discord
</Button>
</form>
);
}

return (
<div className="flex flex-col items-center justify-center gap-4">
<p className="text-center text-2xl">
{session && <span>Logged in as {session.user.name}</span>}
</p>

<form>
<Button
size="lg"
formAction={async () => {
"use server";
await signOut();
}}
>
Sign out
</Button>
</form>
<div className="h-screen">
<UserButton afterSignOutUrl="/" />
</div>
);
}
15 changes: 7 additions & 8 deletions apps/nextjs/src/app/_components/posts.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
"use client";

import type { RouterOutputs } from "@scottylabs/api";
import { use } from "react";

import type { RouterOutputs } from "@acme/api";
import { cn } from "@acme/ui";
import { Button } from "@acme/ui/button";
import { cn } from "@scottylabs/ui";
import { Button } from "@scottylabs/ui/button";
import {
Form,
FormControl,
FormField,
FormItem,
FormMessage,
useForm,
} from "@acme/ui/form";
import { Input } from "@acme/ui/input";
import { toast } from "@acme/ui/toast";
import { CreatePostSchema } from "@acme/validators";
} from "@scottylabs/ui/form";
import { Input } from "@scottylabs/ui/input";
import { toast } from "@scottylabs/ui/toast";
import { CreatePostSchema } from "@scottylabs/validators";

import { api } from "~/trpc/react";

Expand Down
3 changes: 0 additions & 3 deletions apps/nextjs/src/app/api/auth/[...nextauth]/route.ts

This file was deleted.

13 changes: 6 additions & 7 deletions apps/nextjs/src/app/api/trpc/[trpc]/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { NextRequest } from "next/server";
import { getAuth } from "@clerk/nextjs/server";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";

import { appRouter, createTRPCContext } from "@acme/api";
import { auth } from "@acme/auth";

export const runtime = "edge";
import { appRouter, createTRPCContext } from "@scottylabs/api";

/**
* Configure basic CORS headers
Expand All @@ -24,14 +23,14 @@ export function OPTIONS() {
return response;
}

const handler = auth(async (req) => {
const handler = async (req: NextRequest) => {
const response = await fetchRequestHandler({
endpoint: "/api/trpc",
router: appRouter,
req,
createContext: () =>
createTRPCContext({
session: req.auth,
session: getAuth(req),
headers: req.headers,
}),
onError({ error, path }) {
Expand All @@ -41,6 +40,6 @@ const handler = auth(async (req) => {

setCorsHeaders(response);
return response;
});
};

export { handler as GET, handler as POST };
Loading

0 comments on commit 31a11d3

Please sign in to comment.