Skip to content
Closed
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
6 changes: 3 additions & 3 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { styleText } from 'node:util'
import { PassThrough } from 'stream'
import {
createReadableStreamFromReadable,
Expand All @@ -7,7 +8,6 @@ import {
} from '@remix-run/node'
import { RemixServer } from '@remix-run/react'
import * as Sentry from '@sentry/remix'
import chalk from 'chalk'
import { isbot } from 'isbot'
import { renderToPipeableStream } from 'react-dom/server'
import { getEnv, init } from './utils/env.server.ts'
Expand Down Expand Up @@ -102,15 +102,15 @@ export function handleError(
return
}
if (error instanceof Error) {
console.error(chalk.red(error.stack))
console.error(styleText('red', String(error.stack)))
void Sentry.captureRemixServerException(
error,
'remix.server',
request,
true,
)
} else {
console.error(chalk.red(error))
console.error(styleText('red', String(error)))
Sentry.captureException(error)
}
}
5 changes: 3 additions & 2 deletions app/utils/db.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { styleText } from 'node:util'
import { remember } from '@epic-web/remember'
import { PrismaClient } from '@prisma/client'
import chalk from 'chalk'

export const prisma = remember('prisma', () => {
// NOTE: if you change anything in this function you'll need to restart
Expand Down Expand Up @@ -28,7 +28,8 @@ export const prisma = remember('prisma', () => {
: e.duration < logThreshold * 1.4
? 'redBright'
: 'red'
const dur = chalk[color](`${e.duration}ms`)
const dur = styleText(color, `${e.duration}ms`)

console.info(`prisma:query - ${dur} - ${e.query}`)
})
void client.$connect()
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dotenv/config'
// 👆 this needs to imported first

import * as fs from 'fs'
import chalk from 'chalk'
import { styleText } from 'node:util'
import closeWithGrace from 'close-with-grace'
import sourceMapSupport from 'source-map-support'

Expand All @@ -20,8 +22,8 @@ sourceMapSupport.install({

closeWithGrace(async ({ err }) => {
if (err) {
console.error(chalk.red(err))
console.error(chalk.red(err.stack))
console.error(styleText('red', err.message))
console.error(styleText('red', String(err.stack)))
process.exit(1)
}
})
Expand Down
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.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"address": "^2.0.3",
"bcryptjs": "^2.4.3",
"better-sqlite3": "^11.1.2",
"chalk": "^5.3.0",
"class-variance-authority": "^0.7.0",
"close-with-grace": "^1.3.0",
"clsx": "^2.1.1",
Expand Down
10 changes: 5 additions & 5 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import crypto from 'crypto'
import { styleText } from 'node:util'
import { createRequestHandler } from '@remix-run/express'
import { type ServerBuild } from '@remix-run/node'
import { ip as ipAddress } from 'address'
import chalk from 'chalk'
import closeWithGrace from 'close-with-grace'
import compression from 'compression'
import express from 'express'
Expand Down Expand Up @@ -237,7 +237,7 @@ if (!portAvailable && !IS_DEV) {
const server = app.listen(portToUse, () => {
if (!portAvailable) {
console.warn(
chalk.yellow(
styleText('yellow',
`⚠️ Port ${desiredPort} is not available, using ${portToUse} instead.`,
),
)
Expand All @@ -255,9 +255,9 @@ const server = app.listen(portToUse, () => {

console.log(
`
${chalk.bold('Local:')} ${chalk.cyan(localUrl)}
${lanUrl ? `${chalk.bold('On Your Network:')} ${chalk.cyan(lanUrl)}` : ''}
${chalk.bold('Press Ctrl+C to stop')}
${styleText('bold', 'Local:')} ${styleText('cyan', localUrl)}
${lanUrl ? `${styleText('bold', 'On Your Network:')} ${styleText('cyan', lanUrl)}` : ''}
${styleText('bold', 'Press Ctrl+C to stop')}
`.trim(),
)
})
Expand Down