Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: configure logging wrapper #152

Merged
merged 21 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1567d22
feat(logging-wrapper): started configuring package
SamSalvatico Apr 23, 2024
ad436a1
feat(logging-wrapper): added logging wrapper entities
SamSalvatico Apr 23, 2024
8e19fd7
feat(logging-wrapper): add linter
SamSalvatico Apr 23, 2024
862640d
Added fastify wrapper
SamSalvatico Apr 23, 2024
b916ad7
MInified jest config js
SamSalvatico Apr 23, 2024
a548e1a
Updated docs removing Jest
SamSalvatico Apr 23, 2024
b0c8953
Removed jest
SamSalvatico Apr 23, 2024
6508bbc
Fixed lint config
SamSalvatico Apr 23, 2024
f1dde5f
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 23, 2024
f4dbd01
Updated deps
SamSalvatico Apr 23, 2024
a60a8bb
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 24, 2024
9a70c3a
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 26, 2024
40c8830
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 29, 2024
81ac256
Feature: logging wrapper tests (#157)
SamSalvatico Apr 29, 2024
baef20b
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 29, 2024
755f9a7
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 29, 2024
8e02c35
Aligned payments lock
SamSalvatico Apr 29, 2024
da91510
updated to next 14.2.2
SamSalvatico Apr 29, 2024
08dfe48
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 29, 2024
2912ff3
Realigned to dev
SamSalvatico Apr 30, 2024
18e22f9
Merge branch 'dev' into feature/configure-logging-wrapper
SamSalvatico Apr 30, 2024
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
2 changes: 1 addition & 1 deletion apps/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"db-migrate-pg": "^1.5.2",
"design-system": "*",
"feature-flags": "*",
"next": "latest",
"next": "14.2.2",
"next-intl": "^3.7.0",
"pg": "^8.11.3",
"react": "^18.2.0",
Expand Down
24 changes: 4 additions & 20 deletions apps/payments-api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { dirname, join } from "path";
import healthCheck from "./routes/healthcheck";
import sensible from "@fastify/sensible";
import schemaValidators from "./routes/schemas/validations";
import { STATUS_CODES } from "http";
import { initializeErrorHandler } from "error-handler";
import { initializeLoggingHooks } from "logging-wrapper";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand All @@ -23,6 +24,8 @@ dotenv.config();

export async function build(opts?: FastifyServerOptions) {
const app = fastify(opts).withTypeProvider<TypeBoxTypeProvider>();
initializeLoggingHooks(app);
initializeErrorHandler(app);

app.setValidatorCompiler(({ schema }) => {
return schemaValidators(schema);
Expand Down Expand Up @@ -74,24 +77,5 @@ export async function build(opts?: FastifyServerOptions) {

app.register(sensible);

app.setErrorHandler((error, request, reply) => {
app.log.error(error);
if (
error instanceof Error &&
(error.name !== "error" || !!error.validation)
) {
reply.status(error.statusCode || 500).send({
error: STATUS_CODES[error.statusCode || 500],
message: error.message,
name: error.name,
validation: error.validation,
validationContext: error.validationContext,
statusCode: error.statusCode || 500,
});
return;
}
reply.code(500).type("application/json").send({ error });
});

return app;
}
4 changes: 2 additions & 2 deletions apps/payments-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { writeFile } from "fs/promises";

import { getLoggingConfiguration } from "logging-wrapper";
import { build } from "./app";

const app = await build({ logger: true });
const app = await build(getLoggingConfiguration());

app.listen({ host: "0.0.0.0", port: 8001 }, (err, address) => {
if (err) {
Expand Down
4 changes: 4 additions & 0 deletions apps/payments-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"../../packages/auth/src/**/*",
"../../packages/feature-flags/src/**/*",
"../../packages/messages/src/**/*",
"../../packages/logging-wrapper/src/**/*",
"../../packages/error-handler/src/**/*",
"./**/*"
],
"ext": "ts,json",
Expand All @@ -39,6 +41,8 @@
"dotenv": "^16.4.5",
"fastify": "^4.26.2",
"fastify-plugin": "^4.5.1",
"logging-wrapper": "*",
"error-handler": "*",
"pg": "^8.11.3"
},
"devDependencies": {
Expand Down
2 changes: 0 additions & 2 deletions apps/payments/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ COPY ./packages/feature-flags/package*.json /app/packages/feature-flags/
COPY ./packages/auth/package*.json /app/packages/auth/
COPY ./packages/building-blocks-sdk/package*.json /app/packages/building-blocks-sdk/


RUN npm ci

COPY ./apps/payments/ /app/apps/payments/
Expand All @@ -19,7 +18,6 @@ COPY ./packages/feature-flags/ /app/packages/feature-flags/
COPY ./packages/auth/ /app/packages/auth/
COPY ./packages/building-blocks-sdk/ /app/packages/building-blocks-sdk/


FROM deps AS builder
WORKDIR /app
ARG NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The OGCIO design system requires a wrapper for usage within NextJS. This is done

Most building blocks and 3rd party services are mocked in this mono-repo.

Testing around RSC and RSA is still poorly supported. We use Playwright for e2e testing and Jest for unit testing. At the moment there isn't a solid integration testing library for async React components
Testing around RSC and RSA is still poorly supported. We use Playwright for e2e testing and Tap for unit testing. At the moment there isn't a solid integration testing library for async React components

## Setup

Expand Down
Loading