mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
remove apollo server
This commit is contained in:
parent
f287a97a3e
commit
738b7942c1
@ -1,9 +1,5 @@
|
|||||||
CONFIG_VERSION=v1.2023-01-01
|
CONFIG_VERSION=v1.2023-01-01
|
||||||
|
|
||||||
# Server
|
|
||||||
PORT=5000
|
|
||||||
GRAPHIQL=false
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
DB_HOST=localhost
|
DB_HOST=localhost
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
CONFIG_VERSION=$BACKEND_CONFIG_VERSION
|
CONFIG_VERSION=$BACKEND_CONFIG_VERSION
|
||||||
|
|
||||||
# Server
|
|
||||||
GRAPHIQL=false
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
DB_HOST=localhost
|
DB_HOST=localhost
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
|||||||
@ -23,8 +23,6 @@ const constants = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const server = {
|
const server = {
|
||||||
PORT: process.env.PORT || 5000,
|
|
||||||
GRAPHIQL: process.env.GRAPHIQL === 'true' || false,
|
|
||||||
PRODUCTION: process.env.NODE_ENV === 'production' || false,
|
PRODUCTION: process.env.NODE_ENV === 'production' || false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
import { Query, Resolver } from 'type-graphql'
|
|
||||||
|
|
||||||
@Resolver()
|
|
||||||
export class TestResolver {
|
|
||||||
@Query(() => Boolean)
|
|
||||||
async test(): Promise<boolean> {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import { GraphQLSchema } from 'graphql'
|
|
||||||
import { buildSchema } from 'type-graphql'
|
|
||||||
import path from 'path'
|
|
||||||
|
|
||||||
const schema = async (): Promise<GraphQLSchema> => {
|
|
||||||
return await buildSchema({
|
|
||||||
resolvers: [path.join(__dirname, `./resolver/*Resolver.{ts,js}`)],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default schema
|
|
||||||
@ -1,14 +1,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
import createServer from './server/createServer'
|
|
||||||
import { startDHT } from '@/dht_node/index'
|
import { startDHT } from '@/dht_node/index'
|
||||||
|
|
||||||
// config
|
// config
|
||||||
import CONFIG from './config'
|
import CONFIG from './config'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const { app } = await createServer()
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
`starting Federation on ${CONFIG.FEDERATION_DHT_TOPIC} ${
|
`starting Federation on ${CONFIG.FEDERATION_DHT_TOPIC} ${
|
||||||
@ -16,16 +12,6 @@ async function main() {
|
|||||||
}`,
|
}`,
|
||||||
)
|
)
|
||||||
await startDHT(CONFIG.FEDERATION_DHT_TOPIC)
|
await startDHT(CONFIG.FEDERATION_DHT_TOPIC)
|
||||||
|
|
||||||
// management interface
|
|
||||||
app.listen(CONFIG.PORT, () => {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(`Server is running at http://localhost:${CONFIG.PORT}`)
|
|
||||||
if (CONFIG.GRAPHIQL) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((e) => {
|
main().catch((e) => {
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
import cors from 'cors'
|
|
||||||
|
|
||||||
const corsOptions = {
|
|
||||||
origin: '*',
|
|
||||||
exposedHeaders: ['token'],
|
|
||||||
}
|
|
||||||
|
|
||||||
export default cors(corsOptions)
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
import 'reflect-metadata'
|
|
||||||
|
|
||||||
import { ApolloServer } from 'apollo-server-express'
|
|
||||||
import express, { Express } from 'express'
|
|
||||||
|
|
||||||
// database
|
|
||||||
import connection from '@/typeorm/connection'
|
|
||||||
import { checkDBVersion } from '@/typeorm/DBVersion'
|
|
||||||
import cors from './cors'
|
|
||||||
import CONFIG from '@/config'
|
|
||||||
import schema from '@/graphql/schema'
|
|
||||||
import { Connection } from '@dbTools/typeorm'
|
|
||||||
import { apolloLogger } from './logger'
|
|
||||||
import { Logger } from 'log4js'
|
|
||||||
|
|
||||||
type ServerDef = { apollo: ApolloServer; app: Express; con: Connection }
|
|
||||||
|
|
||||||
const createServer = async (logger: Logger = apolloLogger): Promise<ServerDef> => {
|
|
||||||
logger.debug('createServer...')
|
|
||||||
|
|
||||||
// open mysql connection
|
|
||||||
const con = await connection()
|
|
||||||
if (!con || !con.isConnected) {
|
|
||||||
logger.fatal(`Couldn't open connection to database!`)
|
|
||||||
throw new Error(`Fatal: Couldn't open connection to database`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for correct database version
|
|
||||||
const dbVersion = await checkDBVersion(CONFIG.DB_VERSION)
|
|
||||||
if (!dbVersion) {
|
|
||||||
logger.fatal('Fatal: Database Version incorrect')
|
|
||||||
throw new Error('Fatal: Database Version incorrect')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Express Server
|
|
||||||
const app = express()
|
|
||||||
|
|
||||||
// cors
|
|
||||||
app.use(cors)
|
|
||||||
|
|
||||||
// Apollo Server
|
|
||||||
const apollo = new ApolloServer({
|
|
||||||
schema: await schema(),
|
|
||||||
playground: CONFIG.GRAPHIQL,
|
|
||||||
introspection: CONFIG.GRAPHIQL,
|
|
||||||
logger,
|
|
||||||
})
|
|
||||||
apollo.applyMiddleware({ app, path: '/' })
|
|
||||||
logger.debug('createServer...successful')
|
|
||||||
|
|
||||||
return { apollo, app, con }
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createServer
|
|
||||||
Loading…
x
Reference in New Issue
Block a user