Skip to content

Commit

Permalink
refactor: fix sent draft event & optimized filters & optimized packag…
Browse files Browse the repository at this point in the history
…e imports
  • Loading branch information
flxxyz committed May 18, 2023
1 parent 73d61c9 commit 3e16cb4
Show file tree
Hide file tree
Showing 65 changed files with 418 additions and 873 deletions.
26 changes: 23 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"test": "deno test --no-check -A",
"test:unit": "deno test test/unit --no-check -A",
"test:integration": "deno test test/integration --no-check -A",
"example:db:createInstance": "deno run --allow-all src/database/example/createInstance.ts",
"example:db:node": "deno run --allow-all src/database/example/node.ts",
"test:integration:nip01": "deno test test/integration/features/nip-01/nip-01.feature.test.ts --no-check -A",
"test:integration:nip09": "deno test test/integration/features/nip-09/nip-09.feature.test.ts --no-check -A",
"test:integration:nip16": "deno test test/integration/features/nip-16/nip-16.feature.test.ts --no-check -A",
"test:integration:nip28": "deno test test/integration/features/nip-28/nip-28.feature.test.ts --no-check -A",
"test:integration:nip33": "deno test test/integration/features/nip-33/nip-33.feature.test.ts --no-check -A",
"git-hooks": "deno run --no-check=remote --allow-run=deno,git --allow-read --allow-write=.git-hooks https://deno.land/x/githooked/mod.ts install",
"bump": "deno run --allow-all .bump/bump.ts"
},
Expand All @@ -29,7 +32,24 @@
"joi": "https://cdn.skypack.dev/[email protected]?dts",
"rxjs": "https://cdn.skypack.dev/[email protected]?dts",
"chai-as-promised": "https://cdn.skypack.dev/[email protected]?dts",
"events": "https://deno.land/[email protected]/node/events.ts"
"events": "node:events",
"stream": "node:stream",
"stream/promises": "node:stream/promises",
"dns": "node:dns",
"net": "node:net",
"tls": "node:tls",
"path": "node:path",
"os": "node:os",
"fs": "node:fs",
"fs/promises": "node:fs/promises",
"bson": "npm:[email protected]",
"@isaacs/ttlcache": "npm:@isaacs/[email protected]",
"mongodb": "npm:[email protected]",
"mongoose": "npm:[email protected]",
"axios": "npm:[email protected]",
"tor-control-ts": "npm:[email protected]",
"js-yaml": "npm:[email protected]",
"bech32": "npm:[email protected]"
},
"fmt": {
"files": {
Expand Down
122 changes: 53 additions & 69 deletions deno.lock

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

2 changes: 1 addition & 1 deletion src/@types/adapters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventEmitter } from 'node:events'
import { EventEmitter } from 'events'

import { Bulk } from 'redis'

Expand Down
4 changes: 2 additions & 2 deletions src/@types/base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import net from 'node:net'
import net from 'net'

import { Knex } from 'npm:[email protected]'
import mongoose from 'npm:mongoose'
import mongoose from 'mongoose'

import { EventTags } from '../constants/base.ts'

Expand Down
3 changes: 2 additions & 1 deletion src/@types/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Buffer } from 'Buffer'
import { ObjectId } from 'mongodb'

import { ContextMetadataKey, EventDeduplicationMetadataKey, EventDelegatorMetadataKey, EventExpirationTimeMetadataKey, EventKinds } from '../constants/base.ts'
import { ContextMetadata, EventId, Pubkey, Tag } from './base.ts'
Expand Down Expand Up @@ -36,7 +37,7 @@ export interface ParameterizedReplaceableEvent extends Event {
}

export interface DBEvent {
id: string
_id: ObjectId
event_id: Buffer
event_pubkey: Buffer
event_kind: number
Expand Down
9 changes: 4 additions & 5 deletions src/@types/repositories.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { PassThrough } from 'node:stream'
import { PassThrough } from 'stream'

import mongoose from 'npm:mongoose'
import mongoose from 'mongoose'

import { IEvent } from '../database/types/IEvent.ts'
import { DatabaseClient, EventId, Pubkey } from './base.ts'
import { Event } from './event.ts'
import { Event, DBEvent } from './event.ts'
import { Invoice } from './invoice.ts'
import { SubscriptionFilter } from './subscription.ts'
import { User } from './user.ts'
Expand All @@ -18,7 +17,7 @@ export interface IQueryResult<T> extends Pick<Promise<T>, keyof Promise<T> & Exp
export interface IEventRepository {
create(event: Event): Promise<number>
upsert(event: Event): Promise<number>
findByFilters(filters: SubscriptionFilter[]): mongoose.Aggregate<IEvent[]>
findByFilters(filters: SubscriptionFilter[]): mongoose.Aggregate<DBEvent[]>
insertStubs(pubkey: string, eventIdsToDelete: EventId[]): Promise<number>
deleteByPubkeyAndIds(pubkey: Pubkey, ids: EventId[]): Promise<number>
}
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/inmemory-cache-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Bulk } from 'redis'
import TTLCache from 'npm:@isaacs/ttlcache'
import TTLCache from '@isaacs/ttlcache'
import { ICacheAdapter } from '../@types/adapters.ts'
import { createLogger } from '../factories/logger-factory.ts'

Expand Down
Loading

0 comments on commit 3e16cb4

Please sign in to comment.