-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: run prettier format on index.ts
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
1 parent
812ffde
commit 126e4eb
Showing
1 changed file
with
24 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`); | ||
}); | ||
|