docs: add developer step by step installation
This commit is contained in:
@@ -34,12 +34,6 @@ CLOUDFLARE_EMAIL=
|
||||
# Cloudflare zone name, example: wr.do
|
||||
CLOUDFLARE_ZONE_NAME=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# About to be deprecated
|
||||
# -----------------------------------------------------------------------------
|
||||
NEXT_PUBLIC_FREE_RECORD_QUOTA=3
|
||||
NEXT_PUBLIC_FREE_URL_QUOTA=100
|
||||
|
||||
# Open Signup
|
||||
NEXT_PUBLIC_OPEN_SIGNUP=1
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ export async function POST(req: Request) {
|
||||
CLOUDFLARE_ZONE_NAME,
|
||||
CLOUDFLARE_API_KEY,
|
||||
CLOUDFLARE_EMAIL,
|
||||
NEXT_PUBLIC_FREE_RECORD_QUOTA,
|
||||
} = env;
|
||||
|
||||
if (
|
||||
|
||||
@@ -111,6 +111,11 @@ export const docsConfig: DocsConfig = {
|
||||
href: "/docs/developer/installation",
|
||||
icon: "page",
|
||||
},
|
||||
{
|
||||
title: "Quick Start",
|
||||
href: "/docs/developer/quick-start",
|
||||
icon: "page",
|
||||
},
|
||||
{
|
||||
title: "Cloudflare",
|
||||
href: "/docs/developer/cloudflare",
|
||||
|
||||
@@ -2,8 +2,6 @@ import { SidebarNavItem, SiteConfig } from "types";
|
||||
import { env } from "@/env.mjs";
|
||||
|
||||
const site_url = env.NEXT_PUBLIC_APP_URL;
|
||||
const free_recored_quota = env.NEXT_PUBLIC_FREE_RECORD_QUOTA;
|
||||
const free_url_quota = env.NEXT_PUBLIC_FREE_URL_QUOTA;
|
||||
const open_signup = env.NEXT_PUBLIC_OPEN_SIGNUP;
|
||||
const short_domains = env.NEXT_PUBLIC_SHORT_DOMAINS || "";
|
||||
const email_domains = env.NEXT_PUBLIC_EMAIL_DOMAINS || "";
|
||||
@@ -21,10 +19,6 @@ export const siteConfig: SiteConfig = {
|
||||
discord: "https://discord.gg/AHPQYuZu3m",
|
||||
},
|
||||
mailSupport: "support@wr.do",
|
||||
freeQuota: {
|
||||
record: Number(free_recored_quota),
|
||||
url: Number(free_url_quota),
|
||||
},
|
||||
openSignup: open_signup === "1" ? true : false,
|
||||
shortDomains: short_domains.split(","),
|
||||
emailDomains: email_domains.split(","),
|
||||
|
||||
@@ -27,7 +27,7 @@ Alternatively, you can use the `openssl` CLI, `openssl rand -base64 33`.
|
||||
|
||||
Then add it to your `.env` file:
|
||||
|
||||
```js title=".env.local"
|
||||
```js title=".env"
|
||||
AUTH_SECRET = secret;
|
||||
```
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ Copy/paste the `.env.example` in the `.env` file:
|
||||
|----------------------|-------|-------------|
|
||||
| NEXTAUTH_URL | `http://localhost:3000` | The URL of the Next.js application. |
|
||||
| AUTH_SECRET | `123465` | The secret used to encrypt tokens and email verification hashes. |
|
||||
| DATABASE_URL | `file:./db.sqlite` | The path to the postgres database. |
|
||||
| DATABASE_URL | `postgres://username:password@host:port/database` | The path to the postgres database. |
|
||||
| GOOGLE_CLIENT_ID | `123465` | The ID of the Google OAuth client. |
|
||||
| GOOGLE_CLIENT_SECRET | `123465` | The secret of the Google OAuth client. |
|
||||
| GITHUB_ID | `123465` | The ID of the GitHub OAuth client. |
|
||||
@@ -51,8 +51,6 @@ Copy/paste the `.env.example` in the `.env` file:
|
||||
| CLOUDFLARE_ZONE_ID | `123465` | The zone ID for Cloudflare. |
|
||||
| CLOUDFLARE_API_KEY | `123465` | The API key for Cloudflare. |
|
||||
| CLOUDFLARE_EMAIL | `123465` | The email for Cloudflare. |
|
||||
| NEXT_PUBLIC_FREE_RECORD_QUOTA | `3` | The number of free records. |
|
||||
| NEXT_PUBLIC_FREE_URL_QUOTA | `100` | The number of free URLs. |
|
||||
| NEXT_PUBLIC_OPEN_SIGNUP | `1` | Open signup. |
|
||||
| SCREENSHOTONE_BASE_URL | `https://api.example.com` | pending |
|
||||
| GITHUB_TOKEN | `ghp_sscsfarwetqet` | https://github.com/settings/tokens |
|
||||
@@ -67,6 +65,8 @@ Copy/paste the `.env.example` in the `.env` file:
|
||||
- How to get `DATABASE_URL`, see [Database](/docs/developer/database).
|
||||
- How to active email worker, see [Email Worker](/docs/developer/cloudflare-email-worker).
|
||||
|
||||
For step by step installation, see [Quick Start](/docs/developer/quick-start).
|
||||
|
||||
### Configuration part
|
||||
|
||||
Let's check the configuration part for update all environment variables before use `pnpm run dev`.
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
---
|
||||
title: Quick Start for Developer
|
||||
description: Step by step installation
|
||||
---
|
||||
|
||||
## 0. Installation
|
||||
|
||||
```bash
|
||||
git clone https://github.com/oiov/wr.do
|
||||
```
|
||||
|
||||
Enter in the folder and install dependencies for your project:
|
||||
|
||||
```bash
|
||||
cd wrdo
|
||||
pnpm install
|
||||
```
|
||||
|
||||
### Create a `.env` file
|
||||
|
||||
Copy/paste the `.env.example` in the `.env` file
|
||||
|
||||
## 1. Configure the Database
|
||||
|
||||
### Prepare the Server Database Instance and Obtain the Connection URL
|
||||
|
||||
Before deployment, make sure you have prepared a Postgres database instance. You can choose one of the following methods:
|
||||
|
||||
- A. Use Serverless Postgres instances like Vercel / Neon;
|
||||
- B. Use self-deployed Postgres instances like Docker.
|
||||
|
||||
The configuration for both methods is slightly different, and will be distinguished in the next step.
|
||||
|
||||
### Add Environment Variables in Vercel
|
||||
|
||||
In Vercel's deployment environment variables, add `DATABASE_URL` and other environment variables,
|
||||
and fill in the Postgres database connection URL prepared in the previous step.
|
||||
The typical format for the database connection URL is
|
||||
|
||||
`postgres://username:password@host:port/database`.
|
||||
|
||||
```js title=".env"
|
||||
DATABASE_URL=
|
||||
```
|
||||
|
||||
### Deploy Postgres
|
||||
|
||||
```bash
|
||||
pnpm postinstall
|
||||
pnpm db:push
|
||||
```
|
||||
|
||||
### Add the AUTH_SECRET Environment Variable
|
||||
|
||||
The `AUTH_SECRET` environment variable is used to encrypt tokens and email verification hashes(NextAuth.js).
|
||||
You can generate one from https://generate-secret.vercel.app/32:
|
||||
|
||||
```js title=".env"
|
||||
AUTH_SECRET=a3e686f39b2a878c6866e4604e6f1b1b
|
||||
```
|
||||
|
||||
## 2. Configure Authentication Service
|
||||
|
||||
The server-side database needs to be paired with a user authentication service to function properly.
|
||||
Therefore, the corresponding authentication service needs to be configured.
|
||||
|
||||
We provide the following authentication services:
|
||||
|
||||
- Google
|
||||
- Github
|
||||
- LinuxDo
|
||||
- Resend Email Verification
|
||||
|
||||
### Google config
|
||||
|
||||
In this section, you can update these variables:
|
||||
|
||||
```js title=".env"
|
||||
GOOGLE_CLIENT_ID = your_secret_client_id.apps.googleusercontent.com;
|
||||
GOOGLE_CLIENT_SECRET = your_secret_client;
|
||||
```
|
||||
|
||||
See config tutorial in [Authjs - Google OAuth](https://authjs.dev/getting-started/providers/google).
|
||||
|
||||
### Github config
|
||||
|
||||
In this section, you can update these variables:
|
||||
|
||||
```js title=".env"
|
||||
GITHUB_ID = your_secret_client_id;
|
||||
GITHUB_SECRET = your_secret_client;
|
||||
```
|
||||
|
||||
See config tutorial in [Authjs - Github OAuth](https://authjs.dev/getting-started/providers/github).
|
||||
|
||||
### LinuxDo config
|
||||
|
||||
```js title=".env"
|
||||
LinuxDo_CLIENT_ID=
|
||||
LinuxDo_CLIENT_SECRET=
|
||||
```
|
||||
|
||||
See config tutorial in [Connect LinuxDo](https://connect.linux.do).
|
||||
|
||||
### Resend Email Verification config
|
||||
|
||||
<Callout type="note">
|
||||
The email part is similar at the [resend](https://resend.com/) documentation.
|
||||
You can find the official documentation
|
||||
[here](https://authjs.dev/getting-started/installation#setup-environment) if
|
||||
you want.
|
||||
</Callout>
|
||||
|
||||
<Steps>
|
||||
|
||||
#### Create an account
|
||||
|
||||
If don't have an account on Resend, just follow their steps after signup [here](https://resend.com/signup).
|
||||
|
||||
#### Create an API key
|
||||
|
||||
After signin on Resend, he propurse you to create your first API key.
|
||||
|
||||
Copy/paste in your `.env` file.
|
||||
|
||||
```js
|
||||
RESEND_API_KEY = re_your_resend_api_key;
|
||||
```
|
||||
|
||||
</Steps>
|
||||
|
||||
## 3. Cloudflare Configs
|
||||
|
||||
Before you start, you must have a Cloudflare account and be hosted on Cloudflare.
|
||||
|
||||
### Add the CLOUDFLARE_ZONE_ID Environment Variable
|
||||
|
||||
This is the unique identifier for your Cloudflare zone. You can find it in the Cloudflare dashboard under the Overview section of your domain.
|
||||
|
||||
> Follow [this way](https://dash.cloudflare.com/Your_Acount_Id/wr.do), and scroll down to `Zone ID`.
|
||||
|
||||
### Add the CLOUDFLARE_API_KEY Environment Variable
|
||||
|
||||
This is the API key that you use to authenticate requests to the Cloudflare API. You can generate or find your API key in the Cloudflare dashboard under the `profile` -> `api-tokens` section.
|
||||
|
||||
> Follow [https://dash.cloudflare.com/profile/api-tokens](https://dash.cloudflare.com/profile/api-tokens), and scroll down to `API Token`, the `Global API Key` should be used.
|
||||
|
||||
### Add the CLOUDFLARE_EMAIL Environment Variable
|
||||
|
||||
This is the email address associated with your Cloudflare account. It is used for authentication alongside the API key.
|
||||
|
||||
### Add the CLOUDFLARE_ZONE_NAME Environment Variable
|
||||
|
||||
This is the name of your Cloudflare zone. It is used to specify the zone in the Cloudflare API requests.
|
||||
|
||||
In this section, you can update these variables:
|
||||
|
||||
```js title=".env"
|
||||
CLOUDFLARE_ZONE_ID=abcdef1234567890
|
||||
CLOUDFLARE_ZONE_NAME=wr.do
|
||||
CLOUDFLARE_API_KEY=1234567890abcdef1234567890abcdef
|
||||
CLOUDFLARE_EMAIL=user@example.com
|
||||
```
|
||||
|
||||
## 4. Email Worker Configs
|
||||
|
||||
See detail in [Email Worker](/docs/developer/cloudflare-email-worker).
|
||||
|
||||
After you have completed the above steps, you need add a public domain for r2 storage.
|
||||
|
||||
Via `https://dash.cloudflare.com/[account_id]/r2/default/buckets/[bucket]/settings`:
|
||||
|
||||

|
||||
|
||||
```js title=".env"
|
||||
NEXT_PUBLIC_EMAIL_R2_DOMAIN=https://email-attachment.wr.do
|
||||
```
|
||||
|
||||
## 5. Add the Bussiness Configs
|
||||
|
||||
```js title=".env"
|
||||
# Allow anyone to sign up
|
||||
NEXT_PUBLIC_OPEN_SIGNUP=1
|
||||
|
||||
# Short domains. Separated by `,`
|
||||
NEXT_PUBLIC_SHORT_DOMAINS=wr.do,uv.do
|
||||
|
||||
# Email domains. Separated by `,`
|
||||
NEXT_PUBLIC_EMAIL_DOMAINS=wr.do,uv.do
|
||||
```
|
||||
|
||||
## 6. Add the SCREENSHOTONE_BASE_URL Environment Variable
|
||||
|
||||
It's the base URL for the screenshotone API.
|
||||
|
||||
You can deploy your own screenshotone API from [jasonraimondi/url-to-png](https://github.com/jasonraimondi/url-to-png).
|
||||
Deploy docs via [here](https://jasonraimondi.github.io/url-to-png/)
|
||||
|
||||
```js title=".env"
|
||||
SCREENSHOTONE_BASE_URL=https://api.screenshotone.com
|
||||
```
|
||||
|
||||
## 7. Add the GITHUB_TOKEN Environment Variable
|
||||
|
||||
Via https://github.com/settings/tokens to get your token.
|
||||
|
||||
```js title=".env"
|
||||
GITHUB_TOKEN=
|
||||
```
|
||||
## 8. Start the Dev Server
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
Via [http://localhost:3000](http://localhost:3000)
|
||||
@@ -24,8 +24,6 @@ export const env = createEnv({
|
||||
},
|
||||
client: {
|
||||
NEXT_PUBLIC_APP_URL: z.string().min(1),
|
||||
NEXT_PUBLIC_FREE_RECORD_QUOTA: z.string().min(1).default("3"),
|
||||
NEXT_PUBLIC_FREE_URL_QUOTA: z.string().min(1).default("100"),
|
||||
NEXT_PUBLIC_OPEN_SIGNUP: z.string().min(1).default("1"),
|
||||
NEXT_PUBLIC_SHORT_DOMAINS: z.string().min(1).default(""),
|
||||
NEXT_PUBLIC_EMAIL_DOMAINS: z.string().min(1).default(""),
|
||||
@@ -41,8 +39,6 @@ export const env = createEnv({
|
||||
DATABASE_URL: process.env.DATABASE_URL,
|
||||
RESEND_API_KEY: process.env.RESEND_API_KEY,
|
||||
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
|
||||
NEXT_PUBLIC_FREE_RECORD_QUOTA: process.env.NEXT_PUBLIC_FREE_RECORD_QUOTA,
|
||||
NEXT_PUBLIC_FREE_URL_QUOTA: process.env.NEXT_PUBLIC_FREE_URL_QUOTA,
|
||||
NEXT_PUBLIC_OPEN_SIGNUP: process.env.NEXT_PUBLIC_OPEN_SIGNUP,
|
||||
NEXT_PUBLIC_SHORT_DOMAINS: process.env.NEXT_PUBLIC_SHORT_DOMAINS,
|
||||
NEXT_PUBLIC_EMAIL_DOMAINS: process.env.NEXT_PUBLIC_EMAIL_DOMAINS,
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "wr.do",
|
||||
"version": "0.2.1",
|
||||
"private": true,
|
||||
"version": "0.5.0",
|
||||
"author": {
|
||||
"name": "oiov",
|
||||
"url": "https://github.com/oiov"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
+1
-1
File diff suppressed because one or more lines are too long
Vendored
-4
@@ -15,10 +15,6 @@ export type SiteConfig = {
|
||||
feedback: string;
|
||||
discord: string;
|
||||
};
|
||||
freeQuota: {
|
||||
record: number;
|
||||
url: number;
|
||||
};
|
||||
openSignup: boolean;
|
||||
shortDomains: string[];
|
||||
emailDomains: string[];
|
||||
|
||||
Reference in New Issue
Block a user