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.
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
@token={{login.response.body.$.data.access_token}} | ||
|
||
### 管理员登陆 | ||
# @name login | ||
|
||
POST {{base_url}}/admin/login HTTP/1.1 | ||
Content-Type: application/json | ||
|
||
{ | ||
"username": "less", | ||
"password": "less123" | ||
} | ||
|
||
### 获取集合列表 | ||
|
||
GET {{base_url}}/admin/collections | ||
Content-Type: application/json | ||
Authorization: Bearer {{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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as express from 'express' | ||
import { checkPermission } from '../../lib/api/permission' | ||
import { accessor } from '../../lib/db' | ||
import { getLogger } from '../../lib/logger' | ||
|
||
|
||
export const DbmRouter = express.Router() | ||
const logger = getLogger('admin:api') | ||
|
||
|
||
DbmRouter.get('/collections', async (req, res) => { | ||
const requestId = req['requestId'] | ||
logger.info(`[${requestId}] get /collections`) | ||
|
||
// 权限验证 | ||
const code = await checkPermission(req['auth']?.uid, 'collections.get') | ||
if (code) { | ||
return res.status(code).send() | ||
} | ||
|
||
const colls = await accessor.db.collections() | ||
const names = colls.map(coll => coll.collectionName) | ||
|
||
return res.send(names) | ||
}) |
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