-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: 唐琮霖 <[email protected]> Co-authored-by: 一个不知名の睡觉高手 <[email protected]>
- Loading branch information
1 parent
288c942
commit 9360330
Showing
23 changed files
with
419 additions
and
136 deletions.
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
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,10 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.lint": true, | ||
"deno.unstable": true, | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "denoland.vscode-deno", | ||
"[typescriptreact]": { | ||
"editor.defaultFormatter": "denoland.vscode-deno" | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -57,10 +57,14 @@ | |
"@isaacs/ttlcache": "npm:@isaacs/[email protected]", | ||
"mongodb": "npm:[email protected]", | ||
"mongoose": "npm:[email protected]", | ||
"mongoose-paginate": "npm:[email protected]", | ||
"mongoose-aggregate-paginate": "npm:[email protected]", | ||
"axios": "npm:[email protected]", | ||
"tor-control-ts": "npm:[email protected]", | ||
"js-yaml": "npm:[email protected]", | ||
"bech32": "npm:[email protected]" | ||
"bech32": "npm:[email protected]", | ||
"underscore": "npm:[email protected]", | ||
"dayjs": "npm:[email protected]" | ||
}, | ||
"fmt": { | ||
"files": { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
export interface AmountRow { | ||
_id: string | ||
total: number | ||
} |
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
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
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,26 @@ | ||
import { helpers, IController, Request, Response, RouterContext } from '@/@types/controllers.ts' | ||
import { readReplicaEventsModel } from '@/database/models/Events.ts' | ||
import { Sort } from '@/constants/base.ts' | ||
import { toNostrEvent } from '@/utils/event.ts' | ||
|
||
export class EventsController implements IController { | ||
public async handleRequest(_: Request, response: Response, ctx: RouterContext) { | ||
const query = helpers.getQuery(ctx) | ||
const { sortField = 'event_created_at', sortValue = 'desc' } = query | ||
|
||
const limit = query?.limit ? parseInt(query.limit) : 10 | ||
const page = query?.page ? parseInt(query.page) : 1 | ||
const sort = { [sortField]: Sort.DESC } | ||
if (['asc', 'desc'].includes(sortValue)) { | ||
if (sortValue === 'asc') { | ||
sort[sortField] = Sort.ASC | ||
} | ||
} | ||
|
||
response.body = await readReplicaEventsModel.paginate({ event_kind: 1 }, { sort, limit, page }) | ||
.then((result) => ({ | ||
...result, | ||
docs: result.docs.map(toNostrEvent), | ||
})) | ||
} | ||
} |
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
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
Oops, something went wrong.