Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,6 @@
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/diskcloud/service">
</p>

## Example

[![YouTube](https://img.youtube.com/vi/5w1dCYBrf2k/0.jpg)](https://youtu.be/5w1dCYBrf2k)

### 支持功能
> 目前均为免费版本,Plus 版本还在规划中,Lite 和 Full 版本永久免费。

| 功能 | Lite(缩减版) | Full(全量版) | Plus(增强版) |
|--------------|----------------|----------------|--------------|
| 数据出入库 | 否 | 是 | 是 |
| 缩略图 | 否 | 是 | 是 |
| 图片压缩 | 是 | 是 | 是 |
| 返回 md 格式 | 是 | 是 | 是 |
| 保留原始文件 | 是 | 是 | 是 |
| 文件水印 | 否 | 是 | 是 |
| 自动定时备份 | 否 | 否 | 是 |
| 公开失效时间 | 否 | 否 | 是 |
| 高级搜索功能 | 否 | 否 | 是 |

### 使用方法

```shell
Expand All @@ -40,28 +21,6 @@ yarn dev
> 启动完成之后,会自动创建 resource 作为资源文件夹,而 provisional 会作为临时文件夹。后续会考虑开启定时任务进行清理。


### 环境变量

创建一个 `.env.local` 文件,在里面配置对应的环境变量

```env
TINIFY_KEY= #Tinify 压缩图片的key。如果不需要图片压缩则可以不写
INTERNAL_NETWORK_DOMAIN=http://localhost:3000
PUBLIC_NETWORK_DOMAIN=http://localhost:3000
SERVER_PORT=3000
DIALECT=mysql
MYSQL_DATABASE=
MYSQL_HOST=
MYSQL_USER=root
MYSQL_PASSWORD=
MYSQL_PORT=3306
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
USER_LOGIN_TOKEN_EXPIRE_TIME=3600
JWT_EXPIRES_IN=1h
JWT_SECRET=
```

## Contributors 💪

<a href="https://github.com/diskcloud/service/graphs/contributors"><img src="https://opencollective.com/diskcloud/contributors.svg?width=890" /></a>
87 changes: 87 additions & 0 deletions scripts/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Function to prompt user for input with a default value
function Prompt-Input {
param (
[string]$prompt,
[string]$default
)

if ($default) {
$input = Read-Host "$prompt [$default]"
if ([string]::IsNullOrEmpty($input)) {
return $default
} else {
return $input
}
} else {
return Read-Host $prompt
}
}

# Check if .env.local file already exists
if (-Not (Test-Path .\.env.local)) {
# Prompt user for values
$TINIFY_KEY = Prompt-Input "Enter Tinify Key (optional)"
$INTERNAL_NETWORK_DOMAIN = Prompt-Input "Enter Internal Network Domain" "http://localhost:3000"
$PUBLIC_NETWORK_DOMAIN = Prompt-Input "Enter Public Network Domain" "http://localhost:3000"
$SERVER_PORT = Prompt-Input "Enter Server Port" "3000"
$DIALECT = Prompt-Input "Enter Database Dialect" "mysql"
$MYSQL_DATABASE = Prompt-Input "Enter MySQL Database Name"
$MYSQL_HOST = Prompt-Input "Enter MySQL Host"
$MYSQL_USER = Prompt-Input "Enter MySQL User" "root"
$MYSQL_PASSWORD = Prompt-Input "Enter MySQL Password"
$MYSQL_PORT = Prompt-Input "Enter MySQL Port" "3306"
$REDIS_HOST = Prompt-Input "Enter Redis Host" "127.0.0.1"
$REDIS_PORT = Prompt-Input "Enter Redis Port" "6379"
$USER_LOGIN_TOKEN_EXPIRE_TIME = Prompt-Input "Enter User Login Token Expire Time" "3600"
$JWT_EXPIRES_IN = Prompt-Input "Enter JWT Expiry Time" "1h"
$JWT_SECRET = Prompt-Input "Enter JWT Secret"

# Create .env.local file
$envContent = @"
TINIFY_KEY=$TINIFY_KEY
INTERNAL_NETWORK_DOMAIN=$INTERNAL_NETWORK_DOMAIN
PUBLIC_NETWORK_DOMAIN=$PUBLIC_NETWORK_DOMAIN
SERVER_PORT=$SERVER_PORT
DIALECT=$DIALECT
MYSQL_DATABASE=$MYSQL_DATABASE
MYSQL_HOST=$MYSQL_HOST
MYSQL_USER=$MYSQL_USER
MYSQL_PASSWORD=$MYSQL_PASSWORD
MYSQL_PORT=$MYSQL_PORT
REDIS_HOST=$REDIS_HOST
REDIS_PORT=$REDIS_PORT
USER_LOGIN_TOKEN_EXPIRE_TIME=$USER_LOGIN_TOKEN_EXPIRE_TIME
JWT_EXPIRES_IN=$JWT_EXPIRES_IN
JWT_SECRET=$JWT_SECRET
"@

Set-Content -Path .\.env.local -Value $envContent

Write-Output ".env.local file has been created successfully."
} else {
Write-Output ".env.local file already exists. Skipping creation."
}

# Confirm whether to proceed with installation and startup
$proceed = Read-Host "Do you want to proceed with installation and startup? (y/n)"
if ($proceed -ne 'y') {
Write-Output "Setup completed. Exiting."
exit
}

# Select package manager
$packageManager = Read-Host "Which package manager do you want to use? (yarn/npm)"
if ($packageManager -eq 'yarn') {
Write-Output "Using yarn to install dependencies..."
yarn install
Write-Output "Starting the application with yarn..."
yarn prod
} elseif ($packageManager -eq 'npm') {
Write-Output "Using npm to install dependencies..."
npm install
Write-Output "Starting the application with npm..."
npm run prod
} else {
Write-Output "Invalid selection. Exiting."
exit
}
85 changes: 85 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# Function to prompt user for input with a default value
prompt() {
local varname=$1
local prompt=$2
local default=$3
local value

if [ -z "$default" ]; then
read -p "$prompt: " value
else
read -p "$prompt [$default]: " value
value=${value:-$default}
fi

echo "$value"
}

# Check if .env.local file already exists
if [ ! -f .env.local ]; then
# Prompt user for values
TINIFY_KEY=$(prompt "TINIFY_KEY" "Enter Tinify Key (optional)")
INTERNAL_NETWORK_DOMAIN=$(prompt "INTERNAL_NETWORK_DOMAIN" "Enter Internal Network Domain" "http://localhost:3000")
PUBLIC_NETWORK_DOMAIN=$(prompt "PUBLIC_NETWORK_DOMAIN" "Enter Public Network Domain" "http://localhost:3000")
SERVER_PORT=$(prompt "SERVER_PORT" "Enter Server Port" "3000")
DIALECT=$(prompt "DIALECT" "Enter Database Dialect" "mysql")
MYSQL_DATABASE=$(prompt "MYSQL_DATABASE" "Enter MySQL Database Name")
MYSQL_HOST=$(prompt "MYSQL_HOST" "Enter MySQL Host")
MYSQL_USER=$(prompt "MYSQL_USER" "Enter MySQL User" "root")
MYSQL_PASSWORD=$(prompt "MYSQL_PASSWORD" "Enter MySQL Password")
MYSQL_PORT=$(prompt "MYSQL_PORT" "Enter MySQL Port" "3306")
REDIS_HOST=$(prompt "REDIS_HOST" "Enter Redis Host" "127.0.0.1")
REDIS_PORT=$(prompt "REDIS_PORT" "Enter Redis Port" "6379")
USER_LOGIN_TOKEN_EXPIRE_TIME=$(prompt "USER_LOGIN_TOKEN_EXPIRE_TIME" "Enter User Login Token Expire Time" "3600")
JWT_EXPIRES_IN=$(prompt "JWT_EXPIRES_IN" "Enter JWT Expiry Time" "1h")
JWT_SECRET=$(prompt "JWT_SECRET" "Enter JWT Secret")

# Create .env.local file
cat <<EOF > .env.local
TINIFY_KEY=${TINIFY_KEY}
INTERNAL_NETWORK_DOMAIN=${INTERNAL_NETWORK_DOMAIN}
PUBLIC_NETWORK_DOMAIN=${PUBLIC_NETWORK_DOMAIN}
SERVER_PORT=${SERVER_PORT}
DIALECT=${DIALECT}
MYSQL_DATABASE=${MYSQL_DATABASE}
MYSQL_HOST=${MYSQL_HOST}
MYSQL_USER=${MYSQL_USER}
MYSQL_PASSWORD=${MYSQL_PASSWORD}
MYSQL_PORT=${MYSQL_PORT}
REDIS_HOST=${REDIS_HOST}
REDIS_PORT=${REDIS_PORT}
USER_LOGIN_TOKEN_EXPIRE_TIME=${USER_LOGIN_TOKEN_EXPIRE_TIME}
JWT_EXPIRES_IN=${JWT_EXPIRES_IN}
JWT_SECRET=${JWT_SECRET}
EOF

echo ".env.local file has been created successfully."
else
echo ".env.local file already exists. Skipping creation."
fi

# Confirm whether to proceed with installation and startup
read -p "Do you want to proceed with installation and startup? (y/n): " proceed
if [ "$proceed" != "y" ]; then
echo "Setup completed. Exiting."
exit 0
fi

# Select package manager
read -p "Which package manager do you want to use? (yarn/npm): " packageManager
if [ "$packageManager" = "yarn" ]; then
echo "Using yarn to install dependencies..."
yarn install
echo "Starting the application with yarn..."
yarn prod
elif [ "$packageManager" = "npm" ]; then
echo "Using npm to install dependencies..."
npm install
echo "Starting the application with npm..."
npm run prod
else
echo "Invalid selection. Exiting."
exit 1
fi