Skip to content

Commit 71be985

Browse files
committed
fix share update ?
1 parent e53b15b commit 71be985

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/express.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'ut
2222
import api from './routes/api.js';
2323
import api_db from './routes/api.db.js';
2424
import api_ai from './routes/api.ai.js';
25+
import api_firebase from './routes/api.firebase.js';
2526
import api_share from './routes/api.share.js';
2627
import user from './routes/user.js';
2728
import money from './routes/money.js';
@@ -89,6 +90,7 @@ app.use('/money', money);
8990
app.use('/resources', resources);
9091
// secured routes
9192
app.use('/api/ai', requireAuth(), api_ai);
93+
app.use('/api/firebase', requireAuth(), api_firebase);
9294
app.use('/api/share', requireAuth(), api_share);
9395
app.use('/api/db', requireAuth(), api_db);
9496
app.use('/api/notifications', requireAuth(), notifications);
@@ -110,7 +112,8 @@ app.use((req: Request, res: Response) => {
110112
});
111113

112114

113-
async function initializeMCP() {
115+
async function initializeMCP()
116+
{
114117
try {
115118
console.log('Initializing MCP service...');
116119
const mcpService = getMCPService();

src/routes/api.share.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,20 @@ router.post('/:uuid/update', async (req, res) => {
181181

182182
const TheShare = await Share.get(uuid);
183183

184-
if (TheShare) {
184+
if (TheShare)
185+
{
186+
187+
const currentParams = TheShare.params || {};
188+
const newParams = share.params || {};
185189

186-
const updatedShare = { ...TheShare, ...share, params: { passwd: TheShare.params.passwd, ...share.params } };
190+
const updatedShare = {
191+
...TheShare,
192+
...share,
193+
params: {
194+
...currentParams,
195+
...newParams
196+
}
197+
};
187198

188199
await Share.update(updatedShare!);
189200

@@ -197,9 +208,9 @@ router.post('/:uuid/update', async (req, res) => {
197208

198209
}
199210

200-
catch (err) {
201-
res.status(500).json({ error: true, message: err });
202-
return;
211+
catch (err: any) {
212+
res.status(500).json({ error: true, message: err.message || err });
213+
throw new Error(err);
203214
}
204215

205216
})

0 commit comments

Comments
 (0)