|
1 | | -import './instrument.js'; |
2 | | -import express, {type Express} from "express"; |
| 1 | +import "./instrument.js"; |
| 2 | +import express, { type Express } from "express"; |
3 | 3 | import "reflect-metadata"; |
4 | 4 | import cors from "cors"; |
5 | | -import {assertExists} from "./utils/assertExists.js"; |
6 | | -import {yoga} from "./client/graphql.js"; |
| 5 | +import { assertExists } from "./utils/assertExists.js"; |
| 6 | +import { yoga } from "./client/graphql.js"; |
7 | 7 | import swaggerUi from "swagger-ui-express"; |
8 | | -import swaggerJson from "./__generated__/swagger.json" assert {type: "json"} |
9 | | -import {RegisterRoutes} from "./__generated__/routes/routes.js"; |
10 | | -import * as Sentry from '@sentry/node'; |
| 8 | +import swaggerJson from "./__generated__/swagger.json" assert { type: "json" }; |
| 9 | +import { RegisterRoutes } from "./__generated__/routes/routes.js"; |
| 10 | +import * as Sentry from "@sentry/node"; |
| 11 | +import SignatureRequestProcessorCron from "./cron/SignatureRequestProcessing.js"; |
11 | 12 |
|
12 | 13 | // @ts-expect-error BigInt is not supported by JSON |
13 | 14 | BigInt.prototype.toJSON = function () { |
14 | | - const int = Number.parseInt(this.toString()); |
15 | | - return int ?? this.toString(); |
| 15 | + const int = Number.parseInt(this.toString()); |
| 16 | + return int ?? this.toString(); |
16 | 17 | }; |
17 | 18 |
|
18 | 19 | // @ts-expect-error BigInt is not supported by JSON |
19 | 20 | BigInt.prototype.fromJSON = function () { |
20 | | - return BigInt(this.toString()); |
| 21 | + return BigInt(this.toString()); |
21 | 22 | }; |
22 | 23 |
|
23 | 24 | const PORT = assertExists(process.env.PORT, "PORT"); |
24 | 25 |
|
25 | 26 | const app: Express = express(); |
26 | 27 |
|
27 | | -app.use(express.urlencoded({extended: true, limit: '1mb'})); |
28 | | -app.use(express.json({limit: '1mb'})); |
| 28 | +app.use(express.urlencoded({ extended: true, limit: "1mb" })); |
| 29 | +app.use(express.json({ limit: "1mb" })); |
29 | 30 | app.use(cors()); |
30 | 31 |
|
31 | | -app.get('/health', (req, res) => { |
32 | | - const data = { |
33 | | - uptime: process.uptime(), |
34 | | - message: 'OK', |
35 | | - date: new Date() |
36 | | - } |
| 32 | +app.get("/health", (req, res) => { |
| 33 | + const data = { |
| 34 | + uptime: process.uptime(), |
| 35 | + message: "OK", |
| 36 | + date: new Date(), |
| 37 | + }; |
37 | 38 |
|
38 | | - res.status(200).send(data); |
| 39 | + res.status(200).send(data); |
39 | 40 | }); |
40 | 41 |
|
41 | 42 | // Bind GraphQL Yoga to the graphql endpoint to avoid rendering the playground on any path |
42 | 43 | app.use(yoga.graphqlEndpoint, yoga); |
43 | 44 |
|
44 | | -app.use( |
45 | | - "/spec", |
46 | | - swaggerUi.serve, |
47 | | - swaggerUi.setup(swaggerJson) |
48 | | -); |
| 45 | +app.use("/spec", swaggerUi.serve, swaggerUi.setup(swaggerJson)); |
49 | 46 |
|
50 | 47 | RegisterRoutes(app); |
51 | 48 |
|
52 | 49 | // The error handler must be registered before any other error middleware and after all controllers |
53 | 50 | Sentry.setupExpressErrorHandler(app); |
54 | 51 |
|
55 | | -app.listen(PORT, () => { |
56 | | - console.log( |
57 | | - `🕸️ Running a GraphQL API server at http://localhost:${PORT}/v1/graphql` |
58 | | - ); |
| 52 | +// Start Safe signature request processing cron job |
| 53 | +SignatureRequestProcessorCron.start(); |
59 | 54 |
|
60 | | - console.log(`🚀 Running Swagger docs at http://localhost:${PORT}/spec`); |
| 55 | +app.listen(PORT, () => { |
| 56 | + console.log( |
| 57 | + `🕸️ Running a GraphQL API server at http://localhost:${PORT}/v1/graphql`, |
| 58 | + ); |
61 | 59 |
|
| 60 | + console.log(`🚀 Running Swagger docs at http://localhost:${PORT}/spec`); |
62 | 61 | }); |
63 | | - |
0 commit comments