From 533afe48e59500154618f430a3082f2118828860 Mon Sep 17 00:00:00 2001 From: Morgan Ney Date: Fri, 15 Dec 2023 17:00:21 -0600 Subject: [PATCH] fix: bus selector inline error msg. --- compose.production.yaml | 32 ++++++++++++++++--- packages/api/src/index.ts | 3 +- packages/ui/src/components/busSelector.tsx | 11 ++----- packages/ui/src/components/error/selector.tsx | 28 ++++++++++++++++ 4 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 packages/ui/src/components/error/selector.tsx diff --git a/compose.production.yaml b/compose.production.yaml index 49409d2..a94eb03 100644 --- a/compose.production.yaml +++ b/compose.production.yaml @@ -1,12 +1,36 @@ services: db: - restart: always + restart: unless-stopped + logging: + driver: json-file + options: + # Max disk usage 60MB + max-file: 3 + max-size: 20m session: - restart: always + restart: unless-stopped + logging: + driver: json-file + options: + # Max disk usage 60MB + max-file: 3 + max-size: 20m api: - restart: always + restart: unless-stopped + logging: + driver: json-file + options: + # Max disk usage 100MB + max-file: 5 + max-size: 20m environment: NODE_ENV: production DEBUG: "" stage: - restart: always + restart: unless-stopped + logging: + driver: json-file + options: + # Max disk usage 100MB + max-file: 5 + max-size: 20m diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 140fffd..3e4e5c0 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -1,4 +1,4 @@ -import { env } from 'node:process' +import { env, exit } from 'node:process' import http from 'node:http' import makeDebug from 'debug' @@ -53,6 +53,7 @@ if (env.BM_SESSION_STORE === 'redis') { } catch (err) { // eslint-disable-next-line no-console console.error(`Redis client failed to connect: ${err}`) + exit(1) } } diff --git a/packages/ui/src/components/busSelector.tsx b/packages/ui/src/components/busSelector.tsx index a5a82f1..4ee013a 100644 --- a/packages/ui/src/components/busSelector.tsx +++ b/packages/ui/src/components/busSelector.tsx @@ -9,6 +9,7 @@ import { Agencies } from './selectors/agencies.js' import { Routes } from './selectors/routes.js' import { Directions } from './selectors/directions.js' import { Stops } from './selectors/stops.js' +import { SelectorError } from './error/selector.js' import { useGlobals } from '../globals.js' import { useMap } from '../contexts/map.js' @@ -279,17 +280,9 @@ const BusSelector = memo(function BusSelector({ agencies }: BusSelectorProps) { } }, [dispatch, homeStop, agencies, agency, routeName, routes, route, direction, stop]) - if (error instanceof Error) { - return ( -
-

An error occured while getting agency and route information:

-

{error.message}

-
- ) - } - return ( + {error instanceof Error && }
{ evt.preventDefault() diff --git a/packages/ui/src/components/error/selector.tsx b/packages/ui/src/components/error/selector.tsx new file mode 100644 index 0000000..bd7aa6e --- /dev/null +++ b/packages/ui/src/components/error/selector.tsx @@ -0,0 +1,28 @@ +import styled from 'styled-components' +import { Alert } from '@busmap/components/alert' + +import { errors } from '@core/api/errors.js' + +import type { FC } from 'react' + +interface SelectorErrorProps { + err: Error +} + +const Text = styled.p` + && { + margin: 0 0 10px; + } +` +const SelectorError: FC = ({ err }) => { + const message = errors.getMessage(err) + + return ( + + An error occured while getting agency and route information: + {message} + + ) +} + +export { SelectorError }