Skip to content

Commit

Permalink
Dashboard groundwork (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
imxeno authored Jul 14, 2024
1 parent 8c4dfef commit ee44358
Show file tree
Hide file tree
Showing 16 changed files with 3,298 additions and 204 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ node_modules

# Output of the build
dist
out
build

# Turbo
.turbo
out

# Prisma generated files
**/prisma/client

# Environment variables
.env*
!.env.example
!.env.example

# next.js
.next/
next-env.d.ts

# misc
.DS_Store
40 changes: 40 additions & 0 deletions apps/web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/** @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: {
"@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/require-await": "off",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: {
attributes: false,
},
},
],
},
};
module.exports = config;
10 changes: 10 additions & 0 deletions apps/web/next.config.js
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.js");

/** @type {import("next").NextConfig} */
const config = {};

export default config;
37 changes: 37 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@mist/web",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "next lint && biome check ./src",
"lint:fix": "next lint && biome check --apply ./src",
"start": "next start"
},
"dependencies": {
"@mist/database": "workspace:*",
"@t3-oss/env-nextjs": "^0.10.1",
"dotenv": "^16.4.5",
"next": "^14.2.4",
"next-safe-action": "^7.1.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"server-only": "^0.0.1",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/eslint": "^8.56.10",
"@types/node": "^20.14.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.4",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.3",
"typescript": "^5.5.3"
}
}
7 changes: 7 additions & 0 deletions apps/web/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = {
plugins: {
tailwindcss: {},
},
};

module.exports = config;
15 changes: 15 additions & 0 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import "~/styles/globals.css";

import { Inter } from "next/font/google";

const interFont = Inter({ subsets: ["latin"], variable: "--font-inter" });

export default function RootLayout({
children,
}: Readonly<{ children: React.ReactNode }>) {
return (
<html lang="en" className={interFont.variable}>
<body>{children}</body>
</html>
);
}
3 changes: 3 additions & 0 deletions apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async function Home() {
return <div>Hello world!</div>;
}
23 changes: 23 additions & 0 deletions apps/web/src/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as dotenv from "dotenv";

import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

// Explicitly load the .env file from the root of the monorepo
dotenv.config({ path: [".env", "../../.env"] });

export const env = createEnv({
server: {
DATABASE_URL: z.string().url(),
NODE_ENV: z
.enum(["development", "test", "production"])
.default("development"),
},
client: {},
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
},
skipValidation: !!process.env.SKIP_ENV_VALIDATION || !!process.env.CI,
emptyStringAsUndefined: true,
});
16 changes: 16 additions & 0 deletions apps/web/src/server/db.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { PrismaClient } from "@mist/database";
import { env } from "~/env";

const createPrismaClient = () =>
new PrismaClient({
log:
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
});

const globalForPrisma = globalThis as unknown as {
prisma: ReturnType<typeof createPrismaClient> | undefined;
};

export const db = globalForPrisma.prisma ?? createPrismaClient();

if (env.NODE_ENV !== "production") globalForPrisma.prisma = db;
3 changes: 3 additions & 0 deletions apps/web/src/server/safe-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createSafeActionClient } from "next-safe-action";

export const actionClient = createSafeActionClient();
3 changes: 3 additions & 0 deletions apps/web/src/styles/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
14 changes: 14 additions & 0 deletions apps/web/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { type Config } from "tailwindcss";
import { fontFamily } from "tailwindcss/defaultTheme";

export default {
content: ["./src/**/*.tsx"],
theme: {
extend: {
fontFamily: {
sans: ["var(--font-inter)", ...fontFamily.sans],
},
},
},
plugins: [],
} satisfies Config;
42 changes: 42 additions & 0 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,

/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
"checkJs": true,

/* Bundled projects */
"lib": ["dom", "dom.iterable", "ES2022"],
"noEmit": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "preserve",
"plugins": [{ "name": "next" }],
"incremental": true,

/* Path Aliases */
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
}
},
"include": [
".eslintrc.cjs",
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
"**/*.js",
".next/types/**/*.ts"
],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"ignore": ["apps/web/"],
"rules": {
"recommended": true
}
Expand Down
Loading

0 comments on commit ee44358

Please sign in to comment.