Skip to content

Commit

Permalink
style: run prettier format on index.ts
Browse files Browse the repository at this point in the history
The file wasn't prettier formatted yet and making a change to it would
result in a huge diff with 99% styling changes.
  • Loading branch information
pheuberger committed Dec 18, 2024
1 parent 812ffde commit 126e4eb
Showing 1 changed file with 24 additions and 30 deletions.
54 changes: 24 additions & 30 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,57 @@
import './instrument.js';
import express, {type Express} from "express";
import "./instrument.js";
import express, { type Express } from "express";
import "reflect-metadata";
import cors from "cors";
import {assertExists} from "./utils/assertExists.js";
import {yoga} from "./client/graphql.js";
import { assertExists } from "./utils/assertExists.js";
import { yoga } from "./client/graphql.js";
import swaggerUi from "swagger-ui-express";
import swaggerJson from "./__generated__/swagger.json" assert {type: "json"}
import {RegisterRoutes} from "./__generated__/routes/routes.js";
import * as Sentry from '@sentry/node';
import swaggerJson from "./__generated__/swagger.json" assert { type: "json" };
import { RegisterRoutes } from "./__generated__/routes/routes.js";
import * as Sentry from "@sentry/node";

// @ts-expect-error BigInt is not supported by JSON
BigInt.prototype.toJSON = function () {
const int = Number.parseInt(this.toString());
return int ?? this.toString();
const int = Number.parseInt(this.toString());
return int ?? this.toString();
};

// @ts-expect-error BigInt is not supported by JSON
BigInt.prototype.fromJSON = function () {
return BigInt(this.toString());
return BigInt(this.toString());
};

const PORT = assertExists(process.env.PORT, "PORT");

const app: Express = express();

app.use(express.urlencoded({extended: true, limit: '1mb'}));
app.use(express.json({limit: '1mb'}));
app.use(express.urlencoded({ extended: true, limit: "1mb" }));
app.use(express.json({ limit: "1mb" }));
app.use(cors());

app.get('/health', (req, res) => {
const data = {
uptime: process.uptime(),
message: 'OK',
date: new Date()
}
app.get("/health", (req, res) => {
const data = {
uptime: process.uptime(),
message: "OK",
date: new Date(),
};

res.status(200).send(data);
res.status(200).send(data);
});

// Bind GraphQL Yoga to the graphql endpoint to avoid rendering the playground on any path
app.use(yoga.graphqlEndpoint, yoga);

app.use(
"/spec",
swaggerUi.serve,
swaggerUi.setup(swaggerJson)
);
app.use("/spec", swaggerUi.serve, swaggerUi.setup(swaggerJson));

RegisterRoutes(app);

// The error handler must be registered before any other error middleware and after all controllers
Sentry.setupExpressErrorHandler(app);

app.listen(PORT, () => {
console.log(
`🕸️ Running a GraphQL API server at http://localhost:${PORT}/v1/graphql`
);

console.log(`🚀 Running Swagger docs at http://localhost:${PORT}/spec`);
console.log(
`🕸️ Running a GraphQL API server at http://localhost:${PORT}/v1/graphql`,
);

console.log(`🚀 Running Swagger docs at http://localhost:${PORT}/spec`);
});

0 comments on commit 126e4eb

Please sign in to comment.