mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-07 17:23:15 +08:00
feat(wip): 支持 JWT
This commit is contained in:
@@ -20,6 +20,26 @@ export default function register($app) {
|
||||
$app.get('/api/utils/env', getEnv); // get runtime environment
|
||||
$app.get('/api/utils/backup', gistBackup); // gist backup actions
|
||||
$app.get('/api/utils/refresh', refresh);
|
||||
$app.post('/api/jwt', (req, res) => {
|
||||
if (!ENV().isNode) {
|
||||
return failed(
|
||||
res,
|
||||
new RequestInvalidError(
|
||||
'INVALID_ENV',
|
||||
`This endpoint is only available in Node.js environment`,
|
||||
),
|
||||
);
|
||||
}
|
||||
const { payload, options } = req.body;
|
||||
const jwt = eval(`require("jsonwebtoken")`);
|
||||
res.set('Content-Type', 'application/json;charset=utf-8').send({
|
||||
token: jwt.sign(
|
||||
payload,
|
||||
eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH'),
|
||||
options,
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
// Storage management
|
||||
$app.route('/api/storage')
|
||||
|
||||
Reference in New Issue
Block a user