Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules
.DS_store

/build
/server-build
.env
.cache

Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules

/build
/public/build
/server-build
.env

/test-results/
Expand Down
53 changes: 41 additions & 12 deletions app/routes/_auth/auth.$provider/callback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { invariant } from '@epic-web/invariant'
import { faker } from '@faker-js/faker'
import { SetCookie } from '@mjackson/headers'
import { http } from 'msw'
import { type AppLoadContext } from 'react-router'
import { afterEach, expect, test } from 'vitest'
import { twoFAVerificationType } from '#app/routes/settings/profile/two-factor/_layout.tsx'
import { getSessionExpirationDate, sessionKey } from '#app/utils/auth.server.ts'
Expand All @@ -25,9 +26,11 @@ afterEach(async () => {

test('a new user goes to onboarding', async () => {
const request = await setupRequest()
const response = await loader({ request, params: PARAMS, context: {} }).catch(
(e) => e,
)
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
}).catch((e) => e)
expect(response).toHaveRedirect('/onboarding/github')
})

Expand All @@ -39,9 +42,11 @@ test('when auth fails, send the user to login with a toast', async () => {
}),
)
const request = await setupRequest()
const response = await loader({ request, params: PARAMS, context: {} }).catch(
(e) => e,
)
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
}).catch((e) => e)
invariant(response instanceof Response, 'response should be a Response')
expect(response).toHaveRedirect('/login')
await expect(response).toSendToast(
Expand All @@ -60,7 +65,11 @@ test('when a user is logged in, it creates the connection', async () => {
sessionId: session.id,
code: githubUser.code,
})
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
})
expect(response).toHaveRedirect('/settings/profile/connections')
await expect(response).toSendToast(
expect.objectContaining({
Expand Down Expand Up @@ -96,7 +105,11 @@ test(`when a user is logged in and has already connected, it doesn't do anything
sessionId: session.id,
code: githubUser.code,
})
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
})
expect(response).toHaveRedirect('/settings/profile/connections')
await expect(response).toSendToast(
expect.objectContaining({
Expand All @@ -111,7 +124,11 @@ test('when a user exists with the same email, create connection and make session
const email = githubUser.primaryEmail.toLowerCase()
const { userId } = await setupUser({ ...createUser(), email })
const request = await setupRequest({ code: githubUser.code })
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
})

expect(response).toHaveRedirect('/')

Expand Down Expand Up @@ -155,7 +172,11 @@ test('gives an error if the account is already connected to another user', async
sessionId: session.id,
code: githubUser.code,
})
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
})
expect(response).toHaveRedirect('/settings/profile/connections')
await expect(response).toSendToast(
expect.objectContaining({
Expand All @@ -178,7 +199,11 @@ test('if a user is not logged in, but the connection exists, make a session', as
},
})
const request = await setupRequest({ code: githubUser.code })
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
})
expect(response).toHaveRedirect('/')
await expect(response).toHaveSessionForUser(userId)
})
Expand All @@ -202,7 +227,11 @@ test('if a user is not logged in, but the connection exists and they have enable
},
})
const request = await setupRequest({ code: githubUser.code })
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({
request,
params: PARAMS,
context: {} as AppLoadContext,
})
const searchParams = new URLSearchParams({
type: twoFAVerificationType,
target: userId,
Expand Down
5 changes: 1 addition & 4 deletions app/routes/_seo/sitemap[.]xml.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { generateSitemap } from '@nasa-gcn/remix-seo'
import { type ServerBuild } from 'react-router'
import { getDomainUrl } from '#app/utils/misc.tsx'
import { type Route } from './+types/sitemap[.]xml.ts'

export async function loader({ request, context }: Route.LoaderArgs) {
const serverBuild = (await context.serverBuild) as { build: ServerBuild }

// TODO: This is typeerror is coming up since of the remix-run/server-runtime package. We might need to remove/update that one.
// @ts-expect-error
return generateSitemap(request, serverBuild.build.routes, {
return generateSitemap(request, context.serverBuild.routes, {
siteUrl: getDomainUrl(request),
headers: {
'Cache-Control': `public, max-age=${60 * 5}`,
Expand Down
4 changes: 2 additions & 2 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ is a precondition for a "Mock GitHub server" to be installed (with the help of
calls to `https://github.com/login/oauth/access_token` are being intercepted.
But once deployed to an environment where `process.env.MOCKS` is not set to
`'true'` (see how this is done when launching the
[dev server](../server/dev-server.js) and checked in the
[entrypoint](../index.js)), or even when developing _locally_ but not setting
[server](../server/index.ts) and checked in the
[entrypoint](../index.ts)), or even when developing _locally_ but not setting
`GITHUB_CLIENT_ID` to `MOCK_...`, the requests will actually reach the GitHub
auth server. This is where you will want to have a GitHub OAuth application
properly set up, otherwise the logging in with GitHub will fail and a
Expand Down
5 changes: 1 addition & 4 deletions docs/managing-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ If you wish to change the Node.js version, you can do so by updating the
```json
{
"engines": {
"node": "20.3.1"
"node": "^22.18.0"
}
}
```

Make certain you do not use a version range here because this is used in the
`./other/build-server.ts` to compile the express server code.

You will also want to update the `Dockerfile` to use the same version of Node.js
as the `package.json` file.

Expand Down
6 changes: 1 addition & 5 deletions index.js → index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,4 @@ if (process.env.MOCKS === 'true') {
await import('./tests/mocks/index.ts')
}

if (process.env.NODE_ENV === 'production') {
await import('./server-build/index.js')
} else {
await import('./server/index.ts')
}
await import('./server/index.ts')
1 change: 0 additions & 1 deletion other/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ RUN INTERNAL_COMMAND_TOKEN=$(openssl rand -hex 32) && \
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma

COPY --from=build /myapp/server-build /myapp/server-build
COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/package.json /myapp/package.json
COPY --from=build /myapp/prisma /myapp/prisma
Expand Down
50 changes: 0 additions & 50 deletions other/build-server.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package-lock.json

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

17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
"#tests/*": "./tests/*"
},
"scripts": {
"build": "run-s build:*",
"build:remix": "react-router build",
"build:server": "tsx ./other/build-server.ts",
"dev": "cross-env NODE_ENV=development MOCKS=true node ./server/dev-server.js",
"dev:no-mocks": "cross-env NODE_ENV=development node ./server/dev-server.js",
"build": "react-router build",
"dev": "cross-env NODE_ENV=development MOCKS=true node server/index.ts",
"dev:no-mocks": "cross-env NODE_ENV=development node ./server/index.ts",
"format": "prettier --write .",
"lint": "eslint .",
"setup": "npm run build && prisma migrate deploy && prisma generate --sql && playwright install",
"start": "cross-env NODE_ENV=production node .",
"start:mocks": "cross-env NODE_ENV=production MOCKS=true tsx .",
"start": "cross-env NODE_ENV=production node index.ts",
"start:mocks": "cross-env NODE_ENV=production MOCKS=true node index.ts",
"test": "vitest",
"coverage": "vitest run --coverage",
"test:e2e": "npm run test:e2e:dev --silent",
Expand All @@ -34,8 +32,7 @@
"/node_modules",
"/build",
"/public/build",
"/playwright-report",
"/server-build"
"/playwright-report"
],
"dependencies": {
"@conform-to/react": "^1.5.0",
Expand Down Expand Up @@ -157,7 +154,7 @@
"vitest": "^3.1.3"
},
"engines": {
"node": "22"
"node": "^22.18.0"
},
"prisma": {
"seed": "tsx prisma/seed.ts"
Expand Down
1 change: 0 additions & 1 deletion remix.init/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules
.DS_store

/build
/server-build
.env
.cache

Expand Down
23 changes: 23 additions & 0 deletions server/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable import/no-duplicates */
import 'react-router'
import { createRequestHandler } from '@react-router/express'
import express from 'express'
import { type ServerBuild } from 'react-router'

declare module 'react-router' {
interface AppLoadContext {
serverBuild: ServerBuild
}
}

export const app = express()

app.use(
createRequestHandler({
mode: process.env.NODE_ENV ?? 'development',
build: () => import('virtual:react-router/server-build'),
getLoadContext: async () => ({
serverBuild: await import('virtual:react-router/server-build'),
}),
}),
)
18 changes: 0 additions & 18 deletions server/dev-server.js

This file was deleted.

Loading