Skip to content

Commit a594613

Browse files
authored
Drop Node < 18, upgrade devDependencies and CI Actions (#61)
This updates various devDependencies like Jest and Prettier and also the GHA Actions packages. Additionally, it drops support for old Node versions that have fallen out of Node's support window. Specifically, Node 18 and 20 are supported.
1 parent 152d990 commit a594613

File tree

5 files changed

+2389
-2219
lines changed

5 files changed

+2389
-2219
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
node-version: [10.x, 12.x, 14.x]
8+
node-version: [18, 20]
99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-node@v1
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
1212
with:
1313
node-version: ${{ matrix.node-version }}
1414
- name: Cache Node.js modules
15-
uses: actions/cache@v1
15+
uses: actions/cache@v4
1616
with:
1717
path: ${{ github.workspace }}/node_modules
1818
key: ${{ runner.OS }}-${{ matrix.node-version}}-node_modules-${{ hashFiles('yarn.lock') }}

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"expo",
3333
"push-notifications"
3434
],
35-
"author": "support@expo.io",
35+
"author": "support@expo.dev",
3636
"license": "MIT",
3737
"bugs": {
3838
"url": "https://github.com/expo/expo-server-sdk-node/issues"
@@ -44,15 +44,15 @@
4444
"promise-retry": "^2.0.1"
4545
},
4646
"devDependencies": {
47-
"@types/jest": "^27.0.1",
48-
"@types/node-fetch": "^2.5.12",
49-
"@types/promise-retry": "^1.1.3",
50-
"eslint": "^7.32.0",
51-
"eslint-config-universe": "^7.0.1",
47+
"@types/jest": "^29.5.12",
48+
"@types/node-fetch": "^2.6.11",
49+
"@types/promise-retry": "^1.1.6",
50+
"eslint": "^8.57.0",
51+
"eslint-config-universe": "^12.0.0",
5252
"fetch-mock": "^9.11.0",
53-
"jest": "^27.0.6",
54-
"prettier": "^2.3.2",
55-
"ts-jest": "~27.0.5",
56-
"typescript": "^4.3.5"
53+
"jest": "^29.7.0",
54+
"prettier": "^3.2.5",
55+
"ts-jest": "~29.1.2",
56+
"typescript": "^5.4.2"
5757
}
5858
}

src/ExpoClient.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* expo-server-sdk
33
*
44
* Use this if you are running Node on your server backend when you are working with Expo
5-
* https://expo.io
5+
* Application Services
6+
* https://expo.dev
67
*/
78
import assert from 'assert';
89
import { Agent } from 'http';
@@ -47,7 +48,7 @@ export class Expo {
4748
this.limitConcurrentRequests = promiseLimit(
4849
options.maxConcurrentRequests != null
4950
? options.maxConcurrentRequests
50-
: DEFAULT_CONCURRENT_REQUEST_LIMIT
51+
: DEFAULT_CONCURRENT_REQUEST_LIMIT,
5152
);
5253
this.accessToken = options.accessToken;
5354
this.useFcmV1 = options.useFcmV1;
@@ -77,10 +78,9 @@ export class Expo {
7778
* sized chunks.
7879
*/
7980
async sendPushNotificationsAsync(messages: ExpoPushMessage[]): Promise<ExpoPushTicket[]> {
80-
// @ts-expect-error We don't yet have type declarations for URL
8181
const url = new URL(`${BASE_API_URL}/push/send`);
8282
if (typeof this.useFcmV1 === 'boolean') {
83-
url.searchParams.append('useFcmV1', this.useFcmV1);
83+
url.searchParams.append('useFcmV1', String(this.useFcmV1));
8484
}
8585
const actualMessagesCount = Expo._getActualMessageCount(messages);
8686
const data = await this.limitConcurrentRequests(async () => {
@@ -106,15 +106,15 @@ export class Expo {
106106
retries: 2,
107107
factor: 2,
108108
minTimeout: requestRetryMinTimeout,
109-
}
109+
},
110110
);
111111
});
112112

113113
if (!Array.isArray(data) || data.length !== actualMessagesCount) {
114114
const apiError: ExtensibleError = new Error(
115115
`Expected Expo to respond with ${actualMessagesCount} ${
116116
actualMessagesCount === 1 ? 'ticket' : 'tickets'
117-
} but got ${data.length}`
117+
} but got ${data.length}`,
118118
);
119119
apiError.data = data;
120120
throw apiError;
@@ -124,7 +124,7 @@ export class Expo {
124124
}
125125

126126
async getPushNotificationReceiptsAsync(
127-
receiptIds: ExpoPushReceiptId[]
127+
receiptIds: ExpoPushReceiptId[],
128128
): Promise<{ [id: string]: ExpoPushReceipt }> {
129129
const data = await this.requestAsync(`${BASE_API_URL}/push/getReceipts`, {
130130
httpMethod: 'post',
@@ -136,7 +136,7 @@ export class Expo {
136136

137137
if (!data || typeof data !== 'object' || Array.isArray(data)) {
138138
const apiError: ExtensibleError = new Error(
139-
`Expected Expo to respond with a map from receipt IDs to receipts but received data of another type`
139+
`Expected Expo to respond with a map from receipt IDs to receipts but received data of another type`,
140140
);
141141
apiError.data = data;
142142
throw apiError;
@@ -256,7 +256,7 @@ export class Expo {
256256
let result: ApiResult;
257257
try {
258258
result = JSON.parse(textBody);
259-
} catch (e) {
259+
} catch {
260260
const apiError = await this.getTextResponseErrorAsync(response, textBody);
261261
throw apiError;
262262
}
@@ -274,7 +274,7 @@ export class Expo {
274274
let result: ApiResult;
275275
try {
276276
result = JSON.parse(textBody);
277-
} catch (e) {
277+
} catch {
278278
return await this.getTextResponseErrorAsync(response, textBody);
279279
}
280280

@@ -289,7 +289,7 @@ export class Expo {
289289

290290
private async getTextResponseErrorAsync(response: FetchResponse, text: string): Promise<Error> {
291291
const apiError: ExtensibleError = new Error(
292-
`Expo responded with an error with status code ${response.status}: ` + text
292+
`Expo responded with an error with status code ${response.status}: ` + text,
293293
);
294294
apiError.statusCode = response.status;
295295
apiError.errorText = text;

src/__tests__/ExpoClient-test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ describe('sending push notification messages', () => {
6464
const client = new ExpoClient({ useFcmV1: true });
6565
await client.sendPushNotificationsAsync([{ to: 'a' }]);
6666
expect((fetch as any).called('https://exp.host/--/api/v2/push/send?useFcmV1=true')).toBe(
67-
true
67+
true,
6868
);
6969
});
7070

7171
test('sends requests to the Expo API server with useFcmV1=false', async () => {
7272
const client = new ExpoClient({ useFcmV1: false });
7373
await client.sendPushNotificationsAsync([{ to: 'a' }]);
7474
expect((fetch as any).called('https://exp.host/--/api/v2/push/send?useFcmV1=false')).toBe(
75-
true
75+
true,
7676
);
7777
});
7878
});
@@ -103,11 +103,11 @@ describe('sending push notification messages', () => {
103103

104104
const client = new ExpoClient();
105105
await expect(client.sendPushNotificationsAsync([{ to: 'a' }])).rejects.toThrowError(
106-
`Expected Expo to respond with 1 ticket but got 2`
106+
`Expected Expo to respond with 1 ticket but got 2`,
107107
);
108108

109109
await expect(
110-
client.sendPushNotificationsAsync([{ to: 'a' }, { to: 'b' }, { to: 'c' }])
110+
client.sendPushNotificationsAsync([{ to: 'a' }, { to: 'b' }, { to: 'c' }]),
111111
).rejects.toThrowError(`Expected Expo to respond with 3 tickets but got 2`);
112112
});
113113

@@ -131,7 +131,7 @@ describe('sending push notification messages', () => {
131131

132132
const client = new ExpoClient();
133133
await expect(client.sendPushNotificationsAsync([])).rejects.toThrowError(
134-
`Expo responded with an error`
134+
`Expo responded with an error`,
135135
);
136136
});
137137

@@ -157,7 +157,7 @@ describe('sending push notification messages', () => {
157157

158158
const client = new ExpoClient();
159159
await expect(client.sendPushNotificationsAsync([])).rejects.toThrowError(
160-
`Expo responded with an error`
160+
`Expo responded with an error`,
161161
);
162162
});
163163

@@ -169,7 +169,7 @@ describe('sending push notification messages', () => {
169169

170170
const client = new ExpoClient();
171171
await expect(client.sendPushNotificationsAsync([])).rejects.toThrowError(
172-
`Expo responded with an error`
172+
`Expo responded with an error`,
173173
);
174174
});
175175

@@ -214,7 +214,7 @@ describe('sending push notification messages', () => {
214214
errors: [{ code: 'RATE_LIMIT_ERROR', message: `Rate limit exceeded` }],
215215
},
216216
},
217-
{ repeat: 3 }
217+
{ repeat: 3 },
218218
);
219219

220220
const client = new ExpoClient();
@@ -241,17 +241,17 @@ describe('sending push notification messages', () => {
241241
errors: [{ code: 'RATE_LIMIT_ERROR', message: `Rate limit exceeded` }],
242242
},
243243
},
244-
{ repeat: 2 }
244+
{ repeat: 2 },
245245
)
246246
.mock(
247247
'https://exp.host/--/api/v2/push/send',
248248
{ data: mockTickets },
249-
{ overwriteRoutes: false }
249+
{ overwriteRoutes: false },
250250
);
251251

252252
const client = new ExpoClient();
253253
await expect(client.sendPushNotificationsAsync([{ to: 'a' }, { to: 'b' }])).resolves.toEqual(
254-
mockTickets
254+
mockTickets,
255255
);
256256

257257
expect((fetch as any).done()).toBeTruthy();
@@ -285,7 +285,7 @@ describe('retrieving push notification receipts', () => {
285285

286286
const client = new ExpoClient();
287287
const rejection = expect(
288-
client.getPushNotificationReceiptsAsync(['XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'])
288+
client.getPushNotificationReceiptsAsync(['XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX']),
289289
).rejects;
290290
await rejection.toThrowError(`Expected Expo to respond with a map`);
291291
await rejection.toMatchObject({ data: mockReceipts });
@@ -457,12 +457,12 @@ test('can detect an Expo push token', () => {
457457
// FCM
458458
expect(
459459
ExpoClient.isExpoPushToken(
460-
'dOKpuo4qbsM:APA91bHkSmF84ROx7Y-2eMGxc0lmpQeN33ZwDMG763dkjd8yjKK-rhPtiR1OoIWNG5ZshlL8oyxsTnQ5XtahyBNS9mJAvfeE6aHzv_mOF_Ve4vL2po4clMIYYV2-Iea_sZVJF7xFLXih4Y0y88JNYULxFfz-XXXXX'
461-
)
460+
'dOKpuo4qbsM:APA91bHkSmF84ROx7Y-2eMGxc0lmpQeN33ZwDMG763dkjd8yjKK-rhPtiR1OoIWNG5ZshlL8oyxsTnQ5XtahyBNS9mJAvfeE6aHzv_mOF_Ve4vL2po4clMIYYV2-Iea_sZVJF7xFLXih4Y0y88JNYULxFfz-XXXXX',
461+
),
462462
).toBe(false);
463463
// APNs
464464
expect(
465-
ExpoClient.isExpoPushToken('5fa729c6e535eb568g18fdabd35785fc60f41c161d9d7cf4b0bbb0d92437fda0')
465+
ExpoClient.isExpoPushToken('5fa729c6e535eb568g18fdabd35785fc60f41c161d9d7cf4b0bbb0d92437fda0'),
466466
).toBe(false);
467467
});
468468

0 commit comments

Comments
 (0)