-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f6194e
commit 1268eb7
Showing
12 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# twikoo 配置 | ||
|
||
# MongoDB 数据库连接字符串,不传则使用 lokijs | ||
MONGODB_URI= | ||
|
||
# MongoDB 数据库连接字符串,不传则使用 lokijs | ||
MONGO_URL= | ||
|
||
# lokijs 数据库存储路径 | ||
TWIKOO_DATA= './data' | ||
|
||
# 端口号 | ||
TWIKOO_PORT=8080 | ||
|
||
# IP 请求限流,当同一 IP 短时间内请求次数超过阈值将对该 IP 返回错误 | ||
TWIKOO_THROTTLE=250 | ||
|
||
# 为true时只监听本地请求,使得 nginx 等服务器反代之后不暴露原始端口 | ||
TWIKOO_LOCALHOST_ONLY= | ||
|
||
# 日志级别,支持 verbose / info / warn / error | ||
TWIKOO_LOG_LEVEL=info | ||
|
||
# 在一些特殊情况下使用,如使用了CloudFlare CDN 它会将请求 IP 写到请求头的 cf-connecting-ip 字段上,为了能够正确的获取请求 IP 你可以写成 ['headers.cf-connecting-ip'] | ||
TWIKOO_IP_HEADERS=[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.css | ||
*.json | ||
*.md | ||
LICENSE | ||
src/client/lib/marked/* | ||
src/server/self-hosted/data/* | ||
yarn.lock | ||
patches/ | ||
web.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
.DS_Store | ||
dist | ||
data | ||
!.env | ||
|
||
/cypress/videos/ | ||
/cypress/screenshots/ | ||
|
||
# Editor directories and files | ||
.idea | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# pnpm 依赖安装方式 | ||
node-linker=hoisted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.associations": { | ||
"*.config": "xml", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# twikoo 可执行文件 | ||
|
||
## 打包命令 | ||
|
||
```sh | ||
npm run build | ||
``` | ||
|
||
## 可执行文件下载地址 | ||
|
||
[latest](https://github.com/kongxiangyiren/twikoo-pkg/releases/latest) | ||
|
||
## window iis 启动 | ||
|
||
1、[下载安装 aspNetCore](https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/runtime-aspnetcore-8.0.0-windows-hosting-bundle-installer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const { program } = require('commander') | ||
const { join } = require('path') | ||
const { existsSync, writeFileSync, readFileSync } = require('fs') | ||
|
||
program | ||
.name(require('./package.json').name) | ||
.version(require('./package.json').dependencies.tkserver, '-v, --version') | ||
.description( | ||
`DESCRIPTION: | ||
Official website: https://twikoo.js.org/` | ||
) | ||
.addHelpCommand(false) | ||
|
||
program.parse(process.argv) | ||
|
||
// 创建.env文件 | ||
if ( | ||
process.pkg && | ||
!existsSync(join(process.execPath, '..', '.env')) && | ||
existsSync(join(__dirname, '.env')) | ||
) { | ||
writeFileSync( | ||
join(process.execPath, '..', '.env'), | ||
readFileSync(join(__dirname, '.env'), 'utf-8') | ||
) | ||
} | ||
|
||
// 适配iis | ||
if ( | ||
process.pkg && | ||
process.platform === 'win32' && | ||
!existsSync(join(process.execPath, '..', './web.config')) && | ||
existsSync(join(__dirname, './web.config')) | ||
) { | ||
writeFileSync( | ||
join(process.execPath, '..', './web.config'), | ||
readFileSync(join(__dirname, './web.config'), 'utf-8') | ||
) | ||
} | ||
|
||
// 获取env | ||
require('dotenv').config({ | ||
path: | ||
process.pkg && existsSync(join(process.execPath, '..', '.env')) | ||
? join(process.execPath, '..', '.env') | ||
: existsSync(join(__dirname, '.env')) | ||
? join(__dirname, '.env') | ||
: undefined | ||
}) | ||
|
||
// 匹配iis | ||
if (process.env.ASPNETCORE_PORT) { | ||
process.env.TWIKOO_PORT = process.env.ASPNETCORE_PORT | ||
process.env.TWIKOO_LOCALHOST_ONLY = null | ||
} | ||
|
||
require('tkserver') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "twikoo", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"bin": "index.js", | ||
"scripts": { | ||
"start": "node index.js", | ||
"postinstall": "patch-package", | ||
"diff":"patch-package tkserver", | ||
"build": "rimraf ./dist && pkg . -C GZip --no-bytecode --public-packages \"*\" --public" | ||
}, | ||
"pkg": { | ||
"scripts": [], | ||
"assets": [ | ||
"./node_modules/axios/dist/node/axios.cjs", | ||
"./node_modules/@imaegoo/node-ip2region/data/ip2region.db", | ||
"./web.config", | ||
"./.env" | ||
], | ||
"targets": [ | ||
"node18-win-x64", | ||
"node18-linux-x64", | ||
"node18-macos-x64" | ||
], | ||
"outputPath": "dist" | ||
}, | ||
"dependencies": { | ||
"commander": "^11.1.0", | ||
"dotenv": "^16.3.1", | ||
"tkserver": "1.6.30" | ||
}, | ||
"devDependencies": { | ||
"patch-package": "^8.0.0", | ||
"pkg": "5.8.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/node_modules/pkg-fetch/lib-es5/index.js b/node_modules/pkg-fetch/lib-es5/index.js | ||
index 4b1339e..08d09ee 100644 | ||
--- a/node_modules/pkg-fetch/lib-es5/index.js | ||
+++ b/node_modules/pkg-fetch/lib-es5/index.js | ||
@@ -79,7 +79,7 @@ function download(_a, local) { | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
- url = "https://github.com/vercel/pkg-fetch/releases/download/" + tag + "/" + name; | ||
+ url = "https://mirror.ghproxy.com/https://github.com/vercel/pkg-fetch/releases/download/" + tag + "/" + name; | ||
_c.label = 1; | ||
case 1: | ||
_c.trys.push([1, 4, , 5]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/node_modules/tkserver/index.js b/node_modules/tkserver/index.js | ||
index d1fb7c9..a0972a2 100644 | ||
--- a/node_modules/tkserver/index.js | ||
+++ b/node_modules/tkserver/index.js | ||
@@ -210,7 +210,7 @@ function anonymousSignIn (request) { | ||
|
||
async function connectToDatabase () { | ||
if (db) return db | ||
- const dataDir = path.resolve(process.cwd(), process.env.TWIKOO_DATA || './data') | ||
+ const dataDir = path.resolve(process.pkg ? path.join(process.execPath, '..') : process.cwd(), process.env.TWIKOO_DATA || './data') | ||
if (!fs.existsSync(dataDir)) { | ||
fs.mkdirSync(dataDir) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<location path="." inheritInChildApplications="false"> | ||
<system.webServer> | ||
<handlers> | ||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> | ||
</handlers> | ||
<aspNetCore processPath=".\twikoo-win.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="outofprocess" /> | ||
</system.webServer> | ||
</location> | ||
</configuration> |