Skip to content

Commit

Permalink
Remove server.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Murderlon committed Oct 2, 2024
1 parent e602bd0 commit c133757
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 159 deletions.
5 changes: 3 additions & 2 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AppLoadContext, EntryContext } from '@remix-run/node'
import isbot from 'isbot'
import { PassThrough } from 'node:stream'
import crypto from 'node:crypto'
import { RemixServer } from '@remix-run/react'
import { createReadableStreamFromReadable } from '@remix-run/node'
import { renderToPipeableStream } from 'react-dom/server'
Expand All @@ -17,7 +18,7 @@ export default async function handleRequest(
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
loadContext: AppLoadContext,
_: AppLoadContext,
) {
const callbackName = isbot(request.headers.get('user-agent'))
? 'onAllReady'
Expand All @@ -27,7 +28,7 @@ export default async function handleRequest(
* Content Security Policy.
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
*/
const nonce = String(loadContext.cspNonce) ?? undefined
const nonce = crypto.randomBytes(16).toString('hex')

responseHeaders.set(
'Content-Security-Policy',
Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 5 additions & 1 deletion core/drizzle/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { drizzle } from 'drizzle-orm/neon-serverless'
import { Pool } from '@neondatabase/serverless'
import { neonConfig, Pool } from '@neondatabase/serverless'
import { Resource } from 'sst'
import ws from 'ws'

import {
permission,
Expand Down Expand Up @@ -35,6 +36,9 @@ export const schema = {
permissionToRoleRelations,
}

// WebSocket is not globally defined on AWS
neonConfig.webSocketConstructor = ws

export const connection = new Pool({
connectionString: Resource.DATABASE_URL.value,
max: process.env.DB_MIGRATING || process.env.DB_SEEDING ? 1 : undefined,
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"db:migrate": "cross-env DB_MIGRATING=true bunx drizzle-kit generate",
"db:push": "bunx drizzle-kit push",
"db:seed": "cross-env DB_SEEDING=true bun run ./db/seed.ts",
"dev": "node ./server.js",
"dev": "remix vite:dev",
"format": "biome format --write .",
"format:check": "biome format --error-on-warnings .",
"lint": "biome lint --write .",
Expand Down Expand Up @@ -67,6 +67,7 @@
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
"ulid": "^2.3.0",
"ws": "^8.18.0",
"zod": "^3.23.6"
},
"devDependencies": {
Expand All @@ -89,7 +90,9 @@
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
},
"trustedDependencies": ["@biomejs/biome"],
"trustedDependencies": [
"@biomejs/biome"
],
"engines": {
"node": ">=18.0.0"
}
Expand Down
125 changes: 0 additions & 125 deletions server.js

This file was deleted.

59 changes: 30 additions & 29 deletions sst-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
/* This file is auto-generated by SST. Do not edit. */
/* tslint:disable */
/* eslint-disable */
import 'sst'
declare module 'sst' {
import "sst"
export {}
declare module "sst" {
export interface Resource {
DATABASE_URL: {
type: 'sst.sst.Secret'
value: string
"DATABASE_URL": {
"type": "sst.sst.Secret"
"value": string
}
ENCRYPTION_SECRET: {
type: 'sst.sst.Secret'
value: string
"ENCRYPTION_SECRET": {
"type": "sst.sst.Secret"
"value": string
}
HONEYPOT_ENCRYPTION_SEED: {
type: 'sst.sst.Secret'
value: string
"HONEYPOT_ENCRYPTION_SEED": {
"type": "sst.sst.Secret"
"value": string
}
RESEND_API_KEY: {
type: 'sst.sst.Secret'
value: string
"RESEND_API_KEY": {
"type": "sst.sst.Secret"
"value": string
}
Remix: {
type: 'sst.aws.Remix'
url: string
"Remix": {
"type": "sst.aws.Remix"
"url": string
}
SESSION_SECRET: {
type: 'sst.sst.Secret'
value: string
"SESSION_SECRET": {
"type": "sst.sst.Secret"
"value": string
}
STRIPE_PUBLIC_KEY: {
type: 'sst.sst.Secret'
value: string
"STRIPE_PUBLIC_KEY": {
"type": "sst.sst.Secret"
"value": string
}
STRIPE_SECRET_KEY: {
type: 'sst.sst.Secret'
value: string
"STRIPE_SECRET_KEY": {
"type": "sst.sst.Secret"
"value": string
}
StripeWebhookEndpoint: {
type: 'sst.sst.Secret'
value: string
"StripeWebhookEndpoint": {
"type": "sst.sst.Secret"
"value": string
}
}
}

0 comments on commit c133757

Please sign in to comment.