@astralibx/email-account-manager 10.3.0 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2261,8 +2261,16 @@ function createAccountController(EmailAccount, capacityManager, healthTracker, w
2261
2261
  return {
2262
2262
  async list(req, res) {
2263
2263
  try {
2264
- const accounts = await EmailAccount.find().select("-smtp.pass -imap.pass").sort({ createdAt: -1 });
2265
- res.json({ success: true, data: { accounts } });
2264
+ const { status, provider, page, limit } = req.query;
2265
+ const filter = {};
2266
+ if (status) filter.status = status;
2267
+ if (provider) filter.provider = provider;
2268
+ const pageNum = Number(page) || 1;
2269
+ const limitNum = Number(limit) || 20;
2270
+ const skip = (pageNum - 1) * limitNum;
2271
+ const total = await EmailAccount.countDocuments(filter);
2272
+ const accounts = await EmailAccount.find(filter).select("-smtp.pass -imap.pass").sort({ createdAt: -1 }).skip(skip).limit(limitNum);
2273
+ res.json({ success: true, data: { accounts, total } });
2266
2274
  } catch (error) {
2267
2275
  const message = error instanceof Error ? error.message : "Unknown error";
2268
2276
  res.status(500).json({ success: false, error: message });