This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 增加 /login api,并作为默认推荐登录api & 代码和文案优化
- Loading branch information
1 parent
5ea7b60
commit b3012e4
Showing
10 changed files
with
89 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
PORT=3001 | ||
# 如果想自己处理收到消息的逻辑,在下面填上你的API地址, 默认为空 | ||
LOCAL_RECVD_MSG_API= | ||
# 登录地址Token访问地址: http://localhost:3001/loginCheck?token=[LOCAL_LOGIN_API_TOKEN] | ||
# 登录地址Token访问地址: http://localhost:3001/login?token=[LOCAL_LOGIN_API_TOKEN] | ||
# 生成规则:src/utils/index.js -> generateToken | ||
LOCAL_LOGIN_API_TOKEN= |
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,15 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// 获取当前目录下的所有文件 | ||
const files = fs.readdirSync(__dirname); | ||
|
||
files.forEach(file => { | ||
// 排除当前的 index.js 文件 | ||
if (file !== 'index.js') { | ||
// 导入文件 | ||
const module = require(path.join(__dirname, file)); | ||
// 导出文件中的所有内容 | ||
Object.assign(exports, module); | ||
} | ||
}); |
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 @@ | ||
// Token verification middleware | ||
module.exports.verifyToken = (req, res, next) => { | ||
const { token } = req.query; | ||
|
||
if (token !== process.env.globalLoginToken) { | ||
return res.status(401).json({ | ||
success: false, | ||
message: 'Unauthorized: Access is denied due to invalid credentials.' | ||
}); | ||
} | ||
|
||
next(); | ||
}; |
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
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,9 @@ | ||
// Error handling middleware | ||
module.exports.handleError = (fn) => { | ||
return async (req, res) => { | ||
fn(req, res).catch(error => { | ||
console.error('Error handling request:', error); | ||
res.status(500).json({ success: false, message: 'Internal server error.' }); | ||
}); | ||
} | ||
}; |
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 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// 获取当前目录下的所有文件 | ||
const files = fs.readdirSync(__dirname); | ||
|
||
files.forEach(file => { | ||
// 排除当前的 index.js 文件 | ||
if (file !== 'index.js') { | ||
// 导入文件 | ||
const module = require(path.join(__dirname, file)); | ||
// 导出文件中的所有内容 | ||
Object.assign(exports, module); | ||
} | ||
}); |
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