Skip to content

Commit

Permalink
feat: add unlimited upload api in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Mar 10, 2023
1 parent e6bc8fe commit 5ab4829
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 38 deletions.
1 change: 0 additions & 1 deletion docker-compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ MONGO_URL=mongodb://mongo/tailchat
SECRET=

# file
STAIC_HOST="{BACKEND}"
API_URL=https://tailchat-nightly.moonrailgun.com

# minio
Expand Down
85 changes: 53 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ REDIS_URL=redis://localhost:6379/
TRANSPORTER=

# 填写服务端可访问的接口地址
STAIC_HOST="{BACKEND}"
API_URL=

# 文件存储
Expand Down
8 changes: 7 additions & 1 deletion server/admin/app/server/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ broker.start().then(() => {
console.log('Linked to Tailchat network, TRANSPORTER: ', transporter);
});

export function call<T>(actionName: string, params: any): Promise<T> {
export function callBrokerAction<T>(
actionName: string,
params: any,
opts?: Record<string, any>
): Promise<T> {
return broker.call(actionName, params, {
...opts,
meta: {
...opts?.meta,
userId: SYSTEM_USERID,
},
});
Expand Down
6 changes: 4 additions & 2 deletions server/admin/app/server/router/api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Router } from 'express';
import raExpressMongoose from 'express-mongoose-ra-json-server';
import jwt from 'jsonwebtoken';
import { call } from '../broker';
import { callBrokerAction } from '../broker';
import { adminAuth, auth, authSecret } from '../middleware/auth';
import { configRouter } from './config';
import { networkRouter } from './network';
import { fileRouter } from './upload';

const router = Router();

Expand Down Expand Up @@ -41,6 +42,7 @@ router.post('/login', (req, res) => {

router.use('/network', networkRouter);
router.use('/config', configRouter);
router.use('/file', fileRouter);

router.use(
'/users',
Expand All @@ -52,7 +54,7 @@ router.use(
router.delete('/messages/:id', auth(), async (req, res) => {
try {
const messageId = req.params.id;
await call('chat.message.deleteMessage', {
await callBrokerAction('chat.message.deleteMessage', {
messageId,
});

Expand Down
Loading

0 comments on commit 5ab4829

Please sign in to comment.