Skip to content

Commit 91372b4

Browse files
authored
fix: TTL needs to be in seconds not milliseconds (#114)
1 parent c4c1428 commit 91372b4

File tree

7 files changed

+2219
-2254
lines changed

7 files changed

+2219
-2254
lines changed

.github/workflows/test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
with:
1313
node-version: 14
1414
- run: npm ci
15-
- run: npm run build # needs to happen until I figure out a way to hotload it
1615
- name: Test
1716
run: npm run test
1817
lint:

lib/pubsub/getFilteredSubs-test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('collapseKeys', () => {
1313
'b.d': 'hi',
1414
'b.e.f': false,
1515
})
16-
assert.deepEqual(collapseKeys({ a: [1,2,3, { b: 4, c: [], d: null, e: undefined }] }), {
16+
assert.deepEqual(collapseKeys({ a: [1, 2, 3, { b: 4, c: [], d: null, e: undefined }] }), {
1717
'a.0': 1,
1818
'a.1': 2,
1919
'a.2': 3,
@@ -42,13 +42,13 @@ describe('getFilteredSubs', () => {
4242
const subscription = {
4343
id: '1',
4444
topic,
45-
filter: { },
45+
filter: {},
4646
subscriptionId: '1',
47-
subscription: { } as any,
47+
subscription: {} as any,
4848
connectionId: 'abcd',
4949
connectionInitPayload: {},
5050
requestContext: {} as any,
51-
ttl: Date.now() + 100000,
51+
ttl: Math.floor(Date.now() / 1000) + 100000,
5252
createdAt: Date.now(),
5353
}
5454

@@ -64,11 +64,11 @@ describe('getFilteredSubs', () => {
6464
topic,
6565
filter: { language: 'en' },
6666
subscriptionId: '2',
67-
subscription: { } as any,
67+
subscription: {} as any,
6868
connectionId: 'abcd',
6969
connectionInitPayload: {},
7070
requestContext: {} as any,
71-
ttl: Date.now() + 100000,
71+
ttl: Math.floor(Date.now() / 1000) + 100000,
7272
createdAt: Date.now(),
7373
}
7474

@@ -86,11 +86,11 @@ describe('getFilteredSubs', () => {
8686
topic,
8787
filter: { language: 'en ' },
8888
subscriptionId: '12345',
89-
subscription: { } as any,
89+
subscription: {} as any,
9090
connectionId: '1234',
9191
connectionInitPayload: {},
9292
requestContext: {} as any,
93-
ttl: Date.now() + 100000,
93+
ttl: Math.floor(Date.now() / 1000) + 100000,
9494
createdAt: Date.now(),
9595
}
9696

lib/utils/defaultTTL.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export const defaultTTL = (): number => Date.now() + 3 * 1000 * 60 * 60
1+
/**
2+
* Three hours from now
3+
*/
4+
export const defaultTTL = (hours = 3): number => Math.floor(Date.now() / 1000) + (hours * 60 * 60)

mocks/arc-basic-events/app.arc

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ basic-events
33

44
@ws
55

6+
@static
7+
folder dist
8+
69
@tables
710
Connection
811
id *String
@@ -15,7 +18,6 @@ Subscription
1518

1619
Subscription
1720
connectionId *String
18-
# topicAndKey **String
1921
name ConnectionIndex
2022

2123
Subscription

mocks/arc-basic-events/lib/graphql.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2+
require('esbuild-register')
23
const { makeExecutableSchema } = require('@graphql-tools/schema')
34
const { tables: arcTables } = require('@architect/functions')
4-
const { makeServer, subscribe } = require('../../../dist')
5+
const { makeServer, subscribe } = require('../../../lib')
56
const { ApiGatewayManagementApi } = require('aws-sdk')
67
const { GraphQLError } = require('graphql')
78

0 commit comments

Comments
 (0)