diff options
| author | Adam Soltys <[email protected]> | 2024-11-29 23:32:30 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-29 23:32:30 -0800 |
| commit | 05c582f6d0577596bbf079187b14d1fa28d35f75 (patch) | |
| tree | 71d78951df7d3e5fa15b176798e301afac31d112 | |
| parent | a291e249349475f5c4d8c27d111af6d498eefd8f (diff) | |
| download | coinos-server-05c582f6d0577596bbf079187b14d1fa28d35f75.tar.gz coinos-server-05c582f6d0577596bbf079187b14d1fa28d35f75.zip | |
contacts limit
| -rw-r--r-- | index.ts | 2 | ||||
| -rw-r--r-- | routes/users.ts | 9 |
2 files changed, 6 insertions, 5 deletions
@@ -113,7 +113,7 @@ app.post("/subscription/delete", auth, users.deleteSubscription); app.post("/password", auth, users.password); app.post("/pin", auth, users.pin); app.post("/otpsecret", auth, users.otpsecret); -app.get("/contacts", auth, users.contacts); +app.get("/contacts/:limit?", auth, users.contacts); app.get("/:id/items", items.list); app.get("/items/:id", items.get); diff --git a/routes/users.ts b/routes/users.ts index 3381af83..a2b3b407 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -415,9 +415,8 @@ export default { }, async contacts(req, res) { - const { - user: { id }, - } = req; + const { params, user } = req; + const { id } = user; const lastlen = (await g(`${id}:lastlen`)) || 0; const len = await db.lLen(`${id}:payments`); const payments = @@ -441,7 +440,9 @@ export default { await s(`${id}:contacts`, contacts); - res.send(contacts); + let { limit } = params; + limit ||= contacts.length; + res.send(contacts.slice(0, limit)); }, async del(req, res) { |
