feat(create-turbo): apply official-starter transform

This commit is contained in:
Turbobot 2023-09-06 13:53:31 +03:30 committed by Shahrad Elahi
parent 1d3281e32a
commit 14a4cdd591
51 changed files with 4257 additions and 2810 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
**/node_modules/**

View File

@ -1,3 +0,0 @@
{
"extends": "next/core-web-vitals"
}

37
.gitignore vendored
View File

@ -1,35 +1,2 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
.idea
node_modules

40
Dockerfile Normal file
View File

@ -0,0 +1,40 @@
FROM docker.io/library/node:alpine AS deps
WORKDIR /app
LABEL Maintainer="Shahrad Elahi <https://github.com/shahradelahi>"
COPY src/package.json src/pnpm-lock.yaml ./
RUN npm i -g pnpm
RUN pnpm i --frozen-lockfile
# Copy build result to a new image.
# This saves a lot of disk space.
FROM docker.io/library/node:alpine as runner
WORKDIR /app
# Move node_modules one directory up, so during development
# we don't have to mount it in a volume.
# This results in much faster reloading!
#
# Also, some node_modules might be native, and
# the architecture & OS of your development machine might differ
# than what runs inside of docker.
COPY src/ /app/
COPY --from=deps /opt/app/node_modules ./node_modules
# Install Linux packages
RUN apk add -U --no-cache \
wireguard-tools \
dumb-init \
iptables
# Expose UI Ports
EXPOSE 3000/tcp
# Set Environment
ENV DEBUG=Server,WireGuard
# Run Web UI
WORKDIR /app
CMD ["/usr/bin/dumb-init", "node", "server.js"]

42
Dockerfile-Dev Normal file
View File

@ -0,0 +1,42 @@
FROM --platform=$BUILDPLATFORM golang:1.20-alpine as gost
# Convert TARGETPLATFORM to GOARCH format
# https://github.com/tonistiigi/xx
COPY --from=tonistiigi/xx:golang / /
ARG TARGETPLATFORM
RUN apk add --no-cache musl-dev git gcc
WORKDIR /src
RUN git clone https://github.com/ginuerzh/gost.git
ENV GO111MODULE=on
RUN cd gost/cmd/gost && go env && go build -v
FROM docker.io/library/node:alpine
WORKDIR /app
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY --from=golang:1.20-alpine /usr/local/go/ /usr/local/go/
COPY --from=gost /src/gost/cmd/gost/gost /usr/local/bin/gost
COPY src/ /app/
RUN apk add -U --no-cache \
iproute2 iptables net-tools \
screen vim curl bash \
wireguard-tools \
dumb-init \
redis
EXPOSE 3000/tcp
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["npm", "run", "dev"]

View File

@ -1,38 +1 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
# WireGuard GUI (Easy Admin UI)

9
docker-compose.dev.yml Normal file
View File

@ -0,0 +1,9 @@
version: "3.8"
services:
wireadmin:
image: wireadmin
volumes:
- ./src/:/app/
environment:
- UI_PASSWORD=password
- WG_HOST=192.168.1.233

35
docker-compose.yml Normal file
View File

@ -0,0 +1,35 @@
version: "3.8"
services:
wireadmin:
environment:
# ⚠️ Required:
# Change this to your host's public address
- WG_HOST=raspberrypi.local
# Optional:
# - UI_PASSWORD=foobar123
# - WG_PORT=51820
# - WG_DEFAULT_ADDRESS=10.8.0.x
# - WG_DEFAULT_DNS=1.1.1.1
# - WG_MTU=1420
# - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24
# - WG_PRE_UP=echo "Pre Up" > /etc/wireguard/pre-up.txt
# - WG_POST_UP=echo "Post Up" > /etc/wireguard/post-up.txt
# - WG_PRE_DOWN=echo "Pre Down" > /etc/wireguard/pre-down.txt
# - WG_POST_DOWN=echo "Post Down" > /etc/wireguard/post-down.txt
image: shahradel/wireadmin
container_name: wireadmin
volumes:
- ~/.wg-data:/data
ports:
- "51820:51820/udp"
- "3000:3000/tcp"
restart: unless-stopped
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1

21
docker-entrypoint.sh Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/dumb-init /bin/sh
set -e
# Note above that we run dumb-init as PID 1 in order to reap zombie processes
# as well as forward signals to all processes in its session. Normally, sh
# wouldn't do either of these functions so we'd leak zombies as well as do
# unclean termination of all our sub-processes.
# Prevent core dumps
ulimit -c 0
# Checking if there is /data folder
if [ ! -d "/data" ]; then
mkdir -p /data
chmod 744 /data
fi
# Starting Redis server in detached mode
screen -dmS redis bash -c "redis-server --port 6479 --daemonize no --dir /data --appendonly yes"
exec "$@"

View File

@ -1,25 +1,16 @@
{
"name": "wireguard-gui",
"version": "0.1.0",
"private": true,
"name": "wireadmin",
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"dev:image": "cross-env DOCKER_BUILDKIT=1 docker build --tag wireadmin -f Dockerfile-Dev .",
"dev": "docker-compose -f docker-compose.yml -f docker-compose.dev.yml up"
},
"keywords": [],
"author": "Shahrad Elahi <https://github.com/shahradelahi>",
"license": "MIT",
"packageManager": "pnpm@8.7.0",
"dependencies": {
"@types/node": "20.5.8",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"eslint": "8.48.0",
"eslint-config-next": "13.4.19",
"next": "13.4.19",
"postcss": "8.4.29",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3",
"typescript": "5.2.2"
"cross-env": "^7.0.3"
}
}

View File

@ -1,6 +0,0 @@
import '@/styles/globals.css'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}

View File

@ -1,13 +0,0 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'
type Data = {
name: string
}
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
}

View File

@ -1,118 +0,0 @@
import Image from 'next/image'
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
export default function Home() {
return (
<main
className={`flex min-h-screen flex-col items-center justify-between p-24 ${inter.className}`}
>
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
<code className="font-mono font-bold">pages/index.tsx</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className="dark:invert"
width={100}
height={24}
priority
/>
</a>
</div>
</div>
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700/10 after:dark:from-sky-900 after:dark:via-[#0141ff]/40 before:lg:h-[360px]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Docs{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Find in-depth information about Next.js features and API.
</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Learn{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Templates{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Discover and deploy boilerplate example Next.js&nbsp;projects.
</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Deploy{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
)
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>

Before

Width:  |  Height:  |  Size: 629 B

35
src/.gitignore vendored Normal file
View File

@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

38
src/README.md Normal file
View File

@ -0,0 +1,38 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

View File

@ -0,0 +1,28 @@
import React from "react";
import { Layout } from "antd";
import { twMerge } from "tailwind-merge";
const { Header, Footer, Content } = Layout;
export type BasePageProps = {
rootClassName: string
className: string
children: React.ReactNode
}
export default function BasePage(props: BasePageProps): React.ReactElement {
return (
<Layout className={'w-full min-h-screen'}>
<Header>Header</Header>
<Content
className={twMerge(
'w-full max-w-full md:max-w-[700px] lg:max-w-[1140px] xl:max-w-[1300px] 2xl:max-w-[1400px]',
'space-y-3.5',
props.className
)}>
{props.children}
</Content>
<Footer>Footer</Footer>
</Layout>
)
}

298
src/lib/adapter-redis.ts Normal file
View File

@ -0,0 +1,298 @@
import type {
Adapter,
AdapterUser,
AdapterAccount,
AdapterSession,
VerificationToken,
} from "next-auth/adapters"
import type Redis from "ioredis"
/** This is the interface of the Upstash Redis adapter options. */
export interface RedisAdapterOptions {
/**
* The base prefix for your keys
*/
baseKeyPrefix?: string
/**
* The prefix for the `account` key
*/
accountKeyPrefix?: string
/**
* The prefix for the `accountByUserId` key
*/
accountByUserIdPrefix?: string
/**
* The prefix for the `emailKey` key
*/
emailKeyPrefix?: string
/**
* The prefix for the `sessionKey` key
*/
sessionKeyPrefix?: string
/**
* The prefix for the `sessionByUserId` key
*/
sessionByUserIdKeyPrefix?: string
/**
* The prefix for the `user` key
*/
userKeyPrefix?: string
/**
* The prefix for the `verificationToken` key
*/
verificationTokenKeyPrefix?: string
}
export const defaultOptions = {
baseKeyPrefix: "",
accountKeyPrefix: "user:account:",
accountByUserIdPrefix: "user:account:by-user-id:",
emailKeyPrefix: "user:email:",
sessionKeyPrefix: "user:session:",
sessionByUserIdKeyPrefix: "user:session:by-user-id:",
userKeyPrefix: "user:",
verificationTokenKeyPrefix: "user:token:",
}
const isoDateRE =
/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/
function isDate(value: any) {
return value && isoDateRE.test(value) && !isNaN(Date.parse(value))
}
export function hydrateDates(json: object) {
return Object.entries(json).reduce((acc, [key, val]) => {
acc[key] = isDate(val) ? new Date(val as string) : val
return acc
}, {} as any)
}
/**
* ## Setup
*
* Configure Auth.js to use the Upstash Redis Adapter:
*
* ```javascript title="pages/api/auth/[...nextauth].js"
* import NextAuth from "next-auth"
* import GoogleProvider from "next-auth/providers/google"
* import { RedisAdapter } from "@shahrad/redis-adapter"
* import redisClient from "ioredis";
*
* const redis = redisClient(
* process.env.UPSTASH_REDIS_URL,
* process.env.UPSTASH_REDIS_TOKEN
* )
*
* export default NextAuth({
* adapter: RedisAdapter(redis),
* providers: [
* GoogleProvider({
* clientId: process.env.GOOGLE_CLIENT_ID,
* clientSecret: process.env.GOOGLE_CLIENT_SECRET,
* }),
* ],
* })
* ```
*
* ## Advanced usage
*
* ### Using multiple apps with a single Upstash Redis instance
*
* The Upstash free-tier allows for only one Redis instance. If you have multiple Auth.js connected apps using this instance, you need different key prefixes for every app.
*
* You can change the prefixes by passing an `options` object as the second argument to the adapter factory function.
*
* The default values for this object are:
*
* ```js
* const defaultOptions = {
* baseKeyPrefix: "",
* accountKeyPrefix: "user:account:",
* accountByUserIdPrefix: "user:account:by-user-id:",
* emailKeyPrefix: "user:email:",
* sessionKeyPrefix: "user:session:",
* sessionByUserIdKeyPrefix: "user:session:by-user-id:",
* userKeyPrefix: "user:",
* verificationTokenKeyPrefix: "user:token:",
* }
* ```
*
* Usually changing the `baseKeyPrefix` should be enough for this scenario, but for more custom setups, you can also change the prefixes of every single key.
*
* Example:
*
* ```js
* export default NextAuth({
* ...
* adapter: RedisAdapter(redis, {baseKeyPrefix: "app2:"})
* ...
* })
* ```
*/
export function RedisAdapter(
client: Redis,
options: RedisAdapterOptions = {}
): Adapter {
const mergedOptions = {
...defaultOptions,
...options,
}
const { baseKeyPrefix } = mergedOptions
const accountKeyPrefix = baseKeyPrefix + mergedOptions.accountKeyPrefix
const accountByUserIdPrefix =
baseKeyPrefix + mergedOptions.accountByUserIdPrefix
const emailKeyPrefix = baseKeyPrefix + mergedOptions.emailKeyPrefix
const sessionKeyPrefix = baseKeyPrefix + mergedOptions.sessionKeyPrefix
const sessionByUserIdKeyPrefix =
baseKeyPrefix + mergedOptions.sessionByUserIdKeyPrefix
const userKeyPrefix = baseKeyPrefix + mergedOptions.userKeyPrefix
const verificationTokenKeyPrefix =
baseKeyPrefix + mergedOptions.verificationTokenKeyPrefix
const setObjectAsJson = async (key: string, obj: any) =>
await client.set(key, JSON.stringify(obj))
const setAccount = async (id: string, account: AdapterAccount) => {
const accountKey = accountKeyPrefix + id
await setObjectAsJson(accountKey, account)
await client.set(accountByUserIdPrefix + account.userId, accountKey)
return account
}
const getAccount = async (id: string) => {
const account = await client.get(accountKeyPrefix + id) as AdapterSession | null
if (!account) return null
return hydrateDates(account)
}
const setSession = async (
id: string,
session: AdapterSession
): Promise<AdapterSession> => {
const sessionKey = sessionKeyPrefix + id
await setObjectAsJson(sessionKey, session)
await client.set(sessionByUserIdKeyPrefix + session.userId, sessionKey)
return session
}
const getSession = async (id: string) => {
const session = await client.get(sessionKeyPrefix + id) as AdapterSession | null
if (!session) return null
return hydrateDates(session)
}
const setUser = async (
id: string,
user: AdapterUser
): Promise<AdapterUser> => {
await setObjectAsJson(userKeyPrefix + id, user)
await client.set(`${emailKeyPrefix}${user.email as string}`, id)
return user
}
const getUser = async (id: string) => {
const user = await client.get(userKeyPrefix + id) as AdapterUser | null
if (!user) return null
return hydrateDates(user)
}
return {
async createUser(user) {
const id = crypto.randomUUID()
// TypeScript thinks the emailVerified field is missing
// but all fields are copied directly from user, so it's there
return await setUser(id, { ...user, id })
},
getUser,
async getUserByEmail(email) {
const userId = await client.get(emailKeyPrefix + email)
if (!userId) {
return null
}
return await getUser(userId)
},
async getUserByAccount(account) {
const dbAccount = await getAccount(
`${account.provider}:${account.providerAccountId}`
)
if (!dbAccount) return null
return await getUser(dbAccount.userId)
},
async updateUser(updates) {
const userId = updates.id as string
const user = await getUser(userId)
return await setUser(userId, { ...(user as AdapterUser), ...updates })
},
async linkAccount(account) {
const id = `${account.provider}:${account.providerAccountId}`
return await setAccount(id, { ...account, id })
},
createSession: (session) => setSession(session.sessionToken, session),
async getSessionAndUser(sessionToken) {
const session = await getSession(sessionToken)
if (!session) return null
const user = await getUser(session.userId)
if (!user) return null
return { session, user }
},
async updateSession(updates) {
const session = await getSession(updates.sessionToken)
if (!session) return null
return await setSession(updates.sessionToken, { ...session, ...updates })
},
async deleteSession(sessionToken) {
await client.del(sessionKeyPrefix + sessionToken)
},
async createVerificationToken(verificationToken) {
await setObjectAsJson(
verificationTokenKeyPrefix +
verificationToken.identifier +
":" +
verificationToken.token,
verificationToken
)
return verificationToken
},
async useVerificationToken(verificationToken) {
const tokenKey =
verificationTokenKeyPrefix +
verificationToken.identifier +
":" +
verificationToken.token
const token = await client.get(tokenKey) as VerificationToken | null
if (!token) return null
await client.del(tokenKey)
return hydrateDates(token)
// return reviveFromJson(token)
},
async unlinkAccount(account) {
const id = `${account.provider}:${account.providerAccountId}`
const dbAccount = await getAccount(id)
if (!dbAccount) return
const accountKey = `${accountKeyPrefix}${id}`
await client.del(
accountKey,
`${accountByUserIdPrefix} + ${dbAccount.userId as string}`
)
},
async deleteUser(userId) {
const user = await getUser(userId)
if (!user) return
const accountByUserKey = accountByUserIdPrefix + userId
const accountKey = await client.get(accountByUserKey)
const sessionByUserIdKey = sessionByUserIdKeyPrefix + userId
const sessionKey = await client.get(sessionByUserIdKey)
await client.del(
userKeyPrefix + userId,
`${emailKeyPrefix}${user.email as string}`,
accountKey as string,
accountByUserKey,
sessionKey as string,
sessionByUserIdKey
)
},
}
}

11
src/lib/constants.ts Normal file
View File

@ -0,0 +1,11 @@
export const WG_PATH = '/etc/wireguard'
export const WG_PRE_UP = process.env.WG_PRE_UP || ''
export const WG_POST_UP = process.env.WG_POST_UP || ''
export const WG_PRE_DOWN = process.env.WG_PRE_DOWN || ''
export const WG_POST_DOWN = process.env.WG_POST_DOWN || ''
export const IPV4_REGEX = new RegExp(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)

34
src/lib/file-manager.ts Normal file
View File

@ -0,0 +1,34 @@
import fs from "fs";
import path from "path";
export default class FileManager {
static readDirectoryFiles(dir: string): string[] {
const files_ = [];
const files = fs.readdirSync(dir);
for (const i in files) {
const name = dir + '/' + files[i];
if (!fs.statSync(name).isDirectory()) {
files_.push(path.resolve(process.cwd(), name))
}
}
return files_;
}
static readFile(filePath: string): string {
if (!fs.existsSync(filePath)) {
throw new Error('file not found')
}
return fs.readFileSync(filePath, { encoding: 'utf8' })
}
static writeFile(filePath: string, content: string, forced: boolean = false): void {
const dir_ = filePath.split('/')
const dir = dir_.slice(0, dir_.length - 1).join('/')
if (!fs.existsSync(dir) && forced) {
fs.mkdirSync(dir, { mode: 0o744 })
}
fs.writeFileSync(filePath, content,{ encoding: 'utf8' })
}
}

10
src/lib/redis.ts Normal file
View File

@ -0,0 +1,10 @@
import IORedis from "ioredis";
export const client = new IORedis({
port: 6479
});
export type RedisClient = typeof client;
export const WG_SEVER_PATH = `WG::SERVERS`

14
src/lib/safe-serve.ts Normal file
View File

@ -0,0 +1,14 @@
import { NextApiResponse } from "next";
export default async function safeServe(res: NextApiResponse, fn: () => void): Promise<void> {
return new Promise(() => {
try {
fn()
} catch (e) {
console.error('[SafeServe]: ', e)
return res
.status(200)
.json({ ok: false, details: 'Server Internal Error' })
}
})
}

10
src/lib/server-error.ts Normal file
View File

@ -0,0 +1,10 @@
export default class ServerError extends Error {
statusCode
constructor(message: string, statusCode: number = 500) {
super(message);
this.statusCode = statusCode;
}
};

18
src/lib/shell.ts Normal file
View File

@ -0,0 +1,18 @@
import childProcess from "child_process";
export default class Shell {
public static async exec(command: string, ...args: string[]): Promise<string> {
if (process.platform !== 'linux') {
throw new Error('This program is not meant to run on UNIX systems');
}
return new Promise((resolve, reject) => {
const cmd = `${command}${args.length > 0 ? ` ${args.join(' ')}` : ''}`;
childProcess.exec(cmd, { shell: 'bash', }, (err, stdout) => {
if (err) return reject(err);
return resolve(String(stdout).trim());
});
});
}
};

54
src/lib/typings.ts Normal file
View File

@ -0,0 +1,54 @@
import { z } from "zod";
const WgPeerSchema = z.object({
id: z.string().uuid(),
name: z.string().regex(/^[A-Za-z\d\s]{3,32}$/),
publicKey: z.string(),
privateKey: z.string(),
preSharedKey: z.string(),
endpoint: z.string(),
address: z.string(),
latestHandshakeAt: z.string().nullable(),
transferRx: z.number().nullable(),
transferTx: z.number().nullable(),
persistentKeepalive: z.number().nullable(),
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
enabled: z.boolean(),
})
export type WgPeer = z.infer<typeof WgPeerSchema>
// gPmJda6TojTSaJZmsEJjDINKLX+WwMZJch/GNv75R2A=
export interface WgKey {
privateKey: string
publicKey: string
}
export interface WgPeerConfig {
publicKey: string
preSharedKey: string
endpoint: string
allowedIps: string[]
persistentKeepalive: number | null
}
export interface WgServer {
id: string
name: string
address: string
listen: number
}
export interface WgServerConfig {
privateKey: string
address: string
listen: number
preUp: string | null
postUp: string | null
preDown: string | null
postDown: string | null
dns: string | null
mtu: number
}

13
src/lib/utils.ts Normal file
View File

@ -0,0 +1,13 @@
import { IPV4_REGEX } from "@/lib/constants";
export function isValidIPv4(str: string): boolean {
return IPV4_REGEX.test(str);
}
export function isBetween(v:any,n1:number,n2:number): boolean {
if (Number.isNaN(v)){
return false
}
const n = Number(v)
return n1 <= n && n >= n2
}

264
src/lib/wireguard.ts Normal file
View File

@ -0,0 +1,264 @@
import { promises as fs } from "fs";
import path from "path";
import QRCode from "qrcode";
import { WG_PATH } from "@/lib/constants";
import Shell from "@/lib/shell";
export class WireGuardServer {
serverId: number
constructor(serverId: number) {
this.serverId = serverId
}
async getConfig() {
if (!this.__configPromise) {
this.__configPromise = Promise.resolve().then(async () => {
if (!WG_HOST) {
throw new Error('WG_HOST Environment Variable Not Set!');
}
console.log('Loading configuration...')
let config;
try {
config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8');
config = JSON.parse(config);
console.log('Configuration loaded.')
} catch (err) {
// const privateKey = await Shell.exec('wg genkey');
// const publicKey = await Shell.exec(`echo ${privateKey} | wg pubkey`, {
// log: 'echo ***hidden*** | wg pubkey',
// });
const { privateKey, publicKey } = await this.genKey()
const address = WG_DEFAULT_ADDRESS.replace('x', '1');
config = {
server: {
privateKey,
publicKey,
address,
},
clients: {},
};
console.log('Configuration generated.')
}
await this.__saveConfig(config);
await Shell.exec('wg-quick down wg0').catch(() => {
});
await Shell.exec('wg-quick up wg0').catch(err => {
if (err && err.message && err.message.includes('Cannot find device "wg0"')) {
throw new Error('WireGuard exited with the error: Cannot find device "wg0"\nThis usually means that your host\'s kernel does not support WireGuard!');
}
throw err;
});
// await Util.exec(`iptables -t nat -A POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o eth0 -j MASQUERADE`);
// await Util.exec('iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT');
// await Util.exec('iptables -A FORWARD -i wg0 -j ACCEPT');
// await Util.exec('iptables -A FORWARD -o wg0 -j ACCEPT');
await this.__syncConfig();
return config;
});
}
return this.__configPromise;
}
async saveConfig() {
const config = await this.getConfig();
await this.__saveConfig(config);
await this.__syncConfig();
}
async __saveConfig(config: IServerConfig) {
let result = `
[Interface]
PrivateKey = ${config.privateKey}
Address = ${config.address}/24
ListenPort = ${config.listen}
PreUp = ${config.preUp}
PostUp = ${config.postUp}
PreDown = ${config.preDown}
PostDown = ${config.postDown}
`;
for (const { id, ...client } of config.peers) {
if (!client.enabled) continue;
result += `
# Client: ${client.name} (${id})
[Peer]
PublicKey = ${client.publicKey}
PresharedKey = ${client.preSharedKey}
AllowedIPs = ${client.address}/32`;
}
await fs.writeFile(path.join(WG_PATH, `wg${this.serverId}.conf`), result, {
mode: 0o600,
});
}
async getClients() {
const config = await this.getConfig();
const clients = Object.entries(config.clients).map(([ clientId, client ]) => ({
id: clientId,
name: client.name,
enabled: client.enabled,
address: client.address,
publicKey: client.publicKey,
createdAt: new Date(client.createdAt),
updatedAt: new Date(client.updatedAt),
allowedIPs: client.allowedIPs,
persistentKeepalive: null,
latestHandshakeAt: null,
transferRx: null,
transferTx: null,
}));
// Loop WireGuard status
const dump = await Util.exec('wg show wg0 dump', {
log: false,
});
dump
.trim()
.split('\n')
.slice(1)
.forEach(line => {
const [
publicKey,
preSharedKey, // eslint-disable-line no-unused-vars
endpoint, // eslint-disable-line no-unused-vars
allowedIps, // eslint-disable-line no-unused-vars
latestHandshakeAt,
transferRx,
transferTx,
persistentKeepalive,
] = line.split('\t');
const client = clients.find(client => client.publicKey === publicKey);
if (!client) return;
client.latestHandshakeAt = latestHandshakeAt === '0'
? null
: new Date(Number(`${latestHandshakeAt}000`));
client.transferRx = Number(transferRx);
client.transferTx = Number(transferTx);
client.persistentKeepalive = persistentKeepalive;
});
return clients;
}
async getClient(clientId: string): Promise<WgPeer> {
throw new Error('Yet not implanted!');
}
async getClientConfiguration(clientId: string): Promise<string> {
const config = await this.getConfig();
const client = await this.getClient(clientId);
return `
[Interface]
PrivateKey = ${client.privateKey}
Address = ${client.address}/24
${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}` : ''}
${WG_MTU ? `MTU = ${WG_MTU}` : ''}
[Peer]
PublicKey = ${config.server.publicKey}
PresharedKey = ${client.preSharedKey}
AllowedIPs = ${WG_ALLOWED_IPS}
PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE}
Endpoint = ${WG_HOST}:${WG_PORT}`;
}
async getClientQRCodeSVG(clientId: string) {
const config = await this.getClientConfiguration({ clientId });
return QRCode.toString(config, {
type: 'svg',
width: 512,
});
}
async createClient(name: string) {
throw new Error('Yet not implanted!');
}
async deleteClient(clientId: string) {
throw new Error('Yet not implanted!');
}
async enableClient(clientId: string) {
throw new Error('Yet not implanted!');
}
async disableClient(clientId: string) {
throw new Error('Yet not implanted!');
}
async updateClientName(clientId: string) {
throw new Error('Yet not implanted!');
}
async updateClientAddress(clientId: string, address: string) {
throw new Error('Yet not implanted!');
}
}
/**
* Used to read /etc/wireguard/*.conf and sync them with our
* redis server.
*/
async function syncServers(): Promise<boolean> {
throw new Error('Yet not implanted!');
}
export interface IServerConfig extends WgServerConfig {
peers: WgPeer[]
}
export async function generateWgKey(): Promise<WgKey> {
const privateKey = await Shell.exec('wg genkey');
const publicKey = await Shell.exec(`echo ${privateKey} | wg pubkey`);
return { privateKey, publicKey }
}
export async function generateWgServer(config: {
name: string
address: string
port: number
dns?: string
mtu?: number
}): Promise<number> {
const { privateKey, publicKey } = await generateWgKey();
// inside redis create a config list
}
async function f() {
const { privateKey, publicKey } = await generateWgKey()
await generateWgServer({
name: 'Primary',
address: '10.8.0.0',
port: 50210,
mtu: 1420
})
}

5
src/next-env.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

2973
src/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

32
src/package.json Normal file
View File

@ -0,0 +1,32 @@
{
"name": "wireguard-gui",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"packageManager": "npm@9.7.2",
"dependencies": {
"@types/node": "20.5.8",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"antd": "^5.8.6",
"autoprefixer": "10.4.15",
"clsx": "^2.0.0",
"dotenv": "16.3.1",
"ioredis": "5.3.2",
"next": "13.4.19",
"next-auth": "4.23.1",
"postcss": "8.4.29",
"qrcode": "^1.5.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwind-merge": "^1.14.0",
"tailwindcss": "3.3.3",
"typescript": "5.2.2",
"zod": "^3.22.2"
}
}

22
src/pages/_app.tsx Normal file
View File

@ -0,0 +1,22 @@
import "@/styles/globals.css";
import type { AppProps } from "next/app";
import { SessionProvider } from "next-auth/react";
import type { ThemeConfig } from "antd";
import { ConfigProvider } from "antd";
const theme: ThemeConfig = {
token: {
fontSize: 16,
colorPrimary: '#52c41a',
},
};
export default function App({ Component, pageProps: { session, ...pageProps } }: AppProps) {
return (
<SessionProvider session={session}>
<ConfigProvider theme={theme}>
<Component {...pageProps} />
</ConfigProvider>
</SessionProvider>
);
}

View File

@ -0,0 +1,33 @@
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import "dotenv/config";
export default NextAuth({
providers: [
// Credentials-based authentication providers
// get user and password from .env.local
// https://next-auth.js.org/configuration/providers#credentials-based-authentication-providers
CredentialsProvider({
async authorize(credentials, request) {
const { HASHED_PASSWORD } = process.env
if (!HASHED_PASSWORD) {
return {
}
}
const { password } = request.query || {}
if (!password ) {
return null
}
},
name: 'Credentials',
credentials: {},
}),
]
});
function createSession() {
}

18
src/pages/api/ping.ts Normal file
View File

@ -0,0 +1,18 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import { client } from "@/lib/redis";
import safeServe from "@/lib/safe-serve";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
return safeServe(res, async () => {
// create a list for storing the last 10 pings
await client.lpush("pings", Date.now().toString())
await client.ltrim("pings", 0, 9)
const pings = await client.lrange("pings", 0, -1)
return res
.status(200)
.json({ message: 'Pong!', pings })
})
}

View File

@ -0,0 +1,33 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import safeServe from "@/lib/safe-serve";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
return safeServe(res, async () => {
if (req.method === 'PUT') {
return update(req, res)
}
if (req.method === 'DELETE') {
return remove(req, res)
}
return res
.status(400)
.json({ ok: false, details: 'Method not allowed' })
})
}
async function update(req: NextApiRequest, res: NextApiResponse) {
return res
.status(500)
.json({ ok: false, details: 'Not yet implemented!' })
}
async function remove(req: NextApiRequest, res: NextApiResponse) {
return res
.status(500)
.json({ ok: false, details: 'Not yet implemented!' })
}

View File

@ -0,0 +1,51 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import safeServe from "@/lib/safe-serve";
import { z } from "zod";
import { IPV4_REGEX } from "@/lib/constants";
import { client, WG_SEVER_PATH } from "@/lib/redis";
import { isBetween } from "@/lib/utils";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
return safeServe(res, async () => {
if (req.method !== 'POST') {
return res
.status(400)
.json({ ok: false, details: 'Method not allowed' })
}
if (!RequestSchema.safeParse(req.body).success) {
return res
.status(400)
.json({ ok: false, details: 'Bad Request' })
}
const { name, address, listen, dns = null, mtu = 1420 } = req.body
const serversCount = (await client.lrange(WG_SEVER_PATH, 0, -1)).length
const server = {
id: serversCount + 1,
name,
address,
listen,
mtu,
dns
}
await client.lpush(WG_SEVER_PATH, JSON.stringify(server))
return res
.status(200)
.json({ ok: true })
})
}
const RequestSchema = z.object({
name: z.string().regex(/^[A-Za-z\d\s]{3,32}$/),
address: z.string().regex(IPV4_REGEX),
listen: z.string().refine((d) => isBetween(d, 1, 65535)),
dns: z.string().regex(IPV4_REGEX).optional(),
mtu: z.string().refine((d) => isBetween(d, 1, 1500)).optional()
})

View File

@ -0,0 +1,22 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import safeServe from "@/lib/safe-serve";
import { client, WG_SEVER_PATH } from "@/lib/redis";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
return safeServe(res, async () => {
if (req.method !== 'GET') {
return res
.status(400)
.json({ ok: false, details: 'Method not allowed' })
}
const servers = await client.lrange(WG_SEVER_PATH, 0, -1)
return res
.status(200)
.json({ ok: true, result: servers.map((s)=> JSON.parse(s)) })
})
}

12
src/pages/index.tsx Normal file
View File

@ -0,0 +1,12 @@
import { Card } from "antd";
import BasePage from "@/components/BasePage";
export default function Home() {
return (
<BasePage>
<Card>
Hi
</Card>
</BasePage>
);
}

30
src/pages/login.tsx Normal file
View File

@ -0,0 +1,30 @@
import { signIn, signOut, useSession } from "next-auth/react";
import { Button } from "antd";
import BasePage from "@/components/BasePage";
export default function Home() {
const { data: session } = useSession();
async function handleSignIn() {
const result = await signIn('credentials', { redirect: false }, {
password: 'super-secret-password'
})
console.log(result)
}
return (
<BasePage>
{session ?
(
<BasePage>
Signed in <br />
<Button onClick={() => signOut}>Sign out</Button>
</BasePage>
) :
(
<Button onClick={handleSignIn}>Sign in</Button>
)
}
</BasePage>
);
}

BIN
src/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
src/public/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

13
src/styles/globals.css Normal file
View File

@ -0,0 +1,13 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}
body {
color: rgb(var(--foreground-rgb));
}

View File

@ -4,7 +4,7 @@ const config: Config = {
content: [
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}'
],
theme: {
extend: {
@ -13,8 +13,14 @@ const config: Config = {
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
colors: {
primary: {
DEFAULT: '#88161a'
}
}
},
},
darkMode: "class",
plugins: [],
}
export default config

View File

@ -14,7 +14,8 @@
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": ["./*"]
"@/*": ["./*"],
"@lib/*": ["./lib*"],
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],

9
src/turbo.json Normal file
View File

@ -0,0 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"outputs": [".next/**", "!.next/cache/**"]
},
"lint": {}
}
}

View File

@ -1,27 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}
@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}