Skip to content

Commit 1de8367

Browse files
fix(ci): address typecheck and vitest errors
Co-authored-by: me <[email protected]>
1 parent ae44138 commit 1de8367

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

app/routes/_auth/auth.$provider/callback.test.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ import { loader } from './callback.ts'
1919

2020
const ROUTE_PATH = '/auth/github/callback'
2121
const PARAMS = { provider: 'github' }
22+
const LOADER_ARGS_BASE = {
23+
params: PARAMS,
24+
context: {} as AppLoadContext,
25+
unstable_pattern: ROUTE_PATH,
26+
}
2227

2328
afterEach(async () => {
2429
await deleteGitHubUsers()
@@ -28,8 +33,7 @@ test('a new user goes to onboarding', async () => {
2833
const request = await setupRequest()
2934
const response = await loader({
3035
request,
31-
params: PARAMS,
32-
context: {} as AppLoadContext,
36+
...LOADER_ARGS_BASE,
3337
}).catch((e) => e)
3438
expect(response).toHaveRedirect('/onboarding/github')
3539
})
@@ -44,8 +48,7 @@ test('when auth fails, send the user to login with a toast', async () => {
4448
const request = await setupRequest()
4549
const response = await loader({
4650
request,
47-
params: PARAMS,
48-
context: {} as AppLoadContext,
51+
...LOADER_ARGS_BASE,
4952
}).catch((e) => e)
5053
invariant(response instanceof Response, 'response should be a Response')
5154
expect(response).toHaveRedirect('/login')
@@ -67,8 +70,7 @@ test('when a user is logged in, it creates the connection', async () => {
6770
})
6871
const response = await loader({
6972
request,
70-
params: PARAMS,
71-
context: {} as AppLoadContext,
73+
...LOADER_ARGS_BASE,
7274
})
7375
expect(response).toHaveRedirect('/settings/profile/connections')
7476
await expect(response).toSendToast(
@@ -107,8 +109,7 @@ test(`when a user is logged in and has already connected, it doesn't do anything
107109
})
108110
const response = await loader({
109111
request,
110-
params: PARAMS,
111-
context: {} as AppLoadContext,
112+
...LOADER_ARGS_BASE,
112113
})
113114
expect(response).toHaveRedirect('/settings/profile/connections')
114115
await expect(response).toSendToast(
@@ -126,8 +127,7 @@ test('when a user exists with the same email, create connection and make session
126127
const request = await setupRequest({ code: githubUser.code })
127128
const response = await loader({
128129
request,
129-
params: PARAMS,
130-
context: {} as AppLoadContext,
130+
...LOADER_ARGS_BASE,
131131
})
132132

133133
expect(response).toHaveRedirect('/')
@@ -174,8 +174,7 @@ test('gives an error if the account is already connected to another user', async
174174
})
175175
const response = await loader({
176176
request,
177-
params: PARAMS,
178-
context: {} as AppLoadContext,
177+
...LOADER_ARGS_BASE,
179178
})
180179
expect(response).toHaveRedirect('/settings/profile/connections')
181180
await expect(response).toSendToast(
@@ -201,8 +200,7 @@ test('if a user is not logged in, but the connection exists, make a session', as
201200
const request = await setupRequest({ code: githubUser.code })
202201
const response = await loader({
203202
request,
204-
params: PARAMS,
205-
context: {} as AppLoadContext,
203+
...LOADER_ARGS_BASE,
206204
})
207205
expect(response).toHaveRedirect('/')
208206
await expect(response).toHaveSessionForUser(userId)
@@ -229,8 +227,7 @@ test('if a user is not logged in, but the connection exists and they have enable
229227
const request = await setupRequest({ code: githubUser.code })
230228
const response = await loader({
231229
request,
232-
params: PARAMS,
233-
context: {} as AppLoadContext,
230+
...LOADER_ARGS_BASE,
234231
})
235232
const searchParams = new URLSearchParams({
236233
type: twoFAVerificationType,

app/utils/storage.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function uploadToStorage(file: File | FileUpload, key: string) {
1414
const uploadResponse = await fetch(url, {
1515
method: 'PUT',
1616
headers,
17-
body: file instanceof File ? file : file.stream(),
17+
body: file,
1818
})
1919

2020
if (!uploadResponse.ok) {

server/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ const rateLimitDefault = {
102102
// When sitting behind a CDN such as cloudflare, replace fly-client-ip with the CDN
103103
// specific header such as cf-connecting-ip
104104
keyGenerator: (req: express.Request) => {
105-
return req.get('fly-client-ip') ?? ipKeyGenerator(req.ip)
105+
const ip = req.ip ?? req.socket?.remoteAddress
106+
return req.get('fly-client-ip') ?? ipKeyGenerator(ip ?? '0.0.0.0')
106107
},
107108
}
108109

tests/setup/global-setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { execaCommand } from 'execa'
33
import fsExtra from 'fs-extra'
44
import 'dotenv/config'
55
import '#app/utils/env.server.ts'
6-
import '#app/utils/cache.server.ts'
76

87
export const BASE_DATABASE_PATH = path.join(
98
process.cwd(),

0 commit comments

Comments
 (0)