Use Fastify Mercurius and GraphQL contracts
Some checks are pending
Build Docker Image / build (push) Waiting to run

This commit is contained in:
Ruslan Bakiev
2026-06-01 00:25:27 +05:00
parent 430cb1cff6
commit 3229a527cc
5 changed files with 1122 additions and 1852 deletions

View File

@@ -1,22 +1,21 @@
import express from 'express'
import cors from 'cors'
import { ApolloServer } from '@apollo/server'
import { expressMiddleware } from '@apollo/server/express4'
import { typeDefs, resolvers } from './schema.js'
import Fastify from "fastify";
import cors from "@fastify/cors";
import mercurius from "mercurius";
import { typeDefs, resolvers } from "./schema.js";
const PORT = parseInt(process.env.PORT || '8000', 10)
const PORT = Number.parseInt(process.env.PORT || "8000", 10);
const app = express()
app.use(cors({ origin: ['https://optovia.ru'], credentials: true }))
const app = Fastify();
await app.register(cors, { origin: ["https://optovia.ru"], credentials: true });
await app.register(mercurius, {
schema: typeDefs,
resolvers,
path: "/graphql/public",
graphiql: true,
});
const server = new ApolloServer({ typeDefs, resolvers, introspection: true })
await server.start()
app.get("/health", async () => ({ status: "ok" }));
app.use('/graphql/public', express.json(), expressMiddleware(server) as unknown as express.RequestHandler)
app.get('/health', (_, res) => { res.json({ status: 'ok' }) })
app.listen(PORT, '0.0.0.0', () => {
console.log(`Geo server ready on port ${PORT}`)
console.log(` /graphql/public - public (no auth)`)
})
await app.listen({ port: PORT, host: "0.0.0.0" });
console.log(`Geo server ready on port ${PORT}`);
console.log(` /graphql/public - public (no auth)`);