forked from labring/laf
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 新增发布函数、触发器接口;取消 watch 监听发布;支持发布时编译云函数;
- Loading branch information
Showing
10 changed files
with
121 additions
and
80 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
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
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 was deleted.
Oops, something went wrong.
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,86 @@ | ||
import * as express from 'express' | ||
import { publishFunctions } from '../../api/function' | ||
import { checkPermission } from '../../api/permission' | ||
import { publishAccessPolicy } from '../../api/rules' | ||
import { publishTriggers } from '../../api/trigger' | ||
|
||
export const PublishRouter = express.Router() | ||
|
||
/** | ||
* 发布访问策略 | ||
*/ | ||
PublishRouter.post('/policy', async (req, res) => { | ||
|
||
// 权限验证 | ||
const code = await checkPermission(req['auth']?.uid, 'publish.policy') | ||
if (code) { | ||
return res.status(code).send() | ||
} | ||
|
||
try { | ||
const r = await publishAccessPolicy() | ||
|
||
return res.send({ | ||
code: 0, | ||
data: r | ||
}) | ||
} catch (error) { | ||
return res.send({ | ||
code: 1, | ||
error: error | ||
}) | ||
} | ||
}) | ||
|
||
/** | ||
* 发布云函数 | ||
*/ | ||
PublishRouter.post('/functions', async (req, res) => { | ||
|
||
// 权限验证 | ||
const code = await checkPermission(req['auth']?.uid, 'publish.function') | ||
if (code) { | ||
return res.status(code).send() | ||
} | ||
|
||
try { | ||
const r = await publishFunctions() | ||
|
||
return res.send({ | ||
code: 0, | ||
data: r | ||
}) | ||
} catch (error) { | ||
return res.send({ | ||
code: 1, | ||
error: error | ||
}) | ||
} | ||
}) | ||
|
||
|
||
/** | ||
* 发布触发器 | ||
*/ | ||
PublishRouter.post('/triggers', async (req, res) => { | ||
|
||
// 权限验证 | ||
const code = await checkPermission(req['auth']?.uid, 'publish.trigger') | ||
if (code) { | ||
return res.status(code).send() | ||
} | ||
|
||
try { | ||
const r = await publishTriggers() | ||
|
||
return res.send({ | ||
code: 0, | ||
data: r | ||
}) | ||
} catch (error) { | ||
return res.send({ | ||
code: 1, | ||
error: error | ||
}) | ||
} | ||
}) |