mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
first run is working with defaults, buggy per config settings
This commit is contained in:
parent
8276312cce
commit
d3fa08bc48
@ -20,11 +20,12 @@
|
||||
"@types/jsonwebtoken": "^8.5.9",
|
||||
"@types/lodash.clonedeep": "^4.5.7",
|
||||
"@types/node": "^18.11.11",
|
||||
"apollo-server-express": "^3.11.1",
|
||||
"apollo-server-express": "2.25.2",
|
||||
"class-validator": "^0.13.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"decimal.js-light": "^2.5.1",
|
||||
"express": "^4.18.2",
|
||||
"dotenv": "10.0.0",
|
||||
"express": "4.17.1",
|
||||
"graphql": "15.5.1",
|
||||
"i18n": "^0.15.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env)
|
||||
/*
|
||||
import dotenv from 'dotenv'
|
||||
import Decimal from 'decimal.js-light'
|
||||
dotenv.config()
|
||||
/*
|
||||
import Decimal from 'decimal.js-light'
|
||||
|
||||
Decimal.set({
|
||||
precision: 25,
|
||||
@ -120,6 +120,8 @@ if (
|
||||
const federation = {
|
||||
FEDERATION_DHT_TOPIC: process.env.FEDERATION_DHT_TOPIC || null,
|
||||
FEDERATION_DHT_SEED: process.env.FEDERATION_DHT_SEED || null,
|
||||
FEDERATION_PORT: process.env.FEDERATION_PORT || 5001,
|
||||
FEDERATION_API: process.env.FEDERATION_API || '1_0',
|
||||
FEDERATION_COMMUNITY_ACTIVATE_ENDPOINTS:
|
||||
process.env.FEDERATION_COMMUNITY_ACTIVATE_ENDPOINTS === 'true' || false,
|
||||
FEDERATION_COMMUNITY_URL: process.env.FEDERATION_COMMUNITY_URL || null,
|
||||
|
||||
@ -1,8 +1,56 @@
|
||||
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
/*
|
||||
|
||||
@ObjectType()
|
||||
export class GetTestApiResult {
|
||||
constructor(apiVersion: string) {
|
||||
this.api = `test ${apiVersion}`
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
api: string
|
||||
}
|
||||
|
||||
export class TestResolver {
|
||||
@Query(() => GetTestApiResult)
|
||||
async test(): Promise<String> {
|
||||
const api = `1_0`
|
||||
logger.info(`test apiVersion=1_0`)
|
||||
return 'test 1_0'
|
||||
return new GetTestApiResult(api)
|
||||
}
|
||||
}
|
||||
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const test = gql`
|
||||
query {
|
||||
test {
|
||||
api
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@ObjectType()
|
||||
class GetTestApiResult {
|
||||
constructor(apiVersion: string) {
|
||||
this.api = `test ${apiVersion}`
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
api: string
|
||||
}
|
||||
|
||||
@Resolver()
|
||||
export class TestResolver {
|
||||
@Query(() => GetTestApiResult)
|
||||
async test(): Promise<GetTestApiResult> {
|
||||
logger.info(`test api 1_0`)
|
||||
return new GetTestApiResult("1_0")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,56 @@
|
||||
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
/*
|
||||
|
||||
@ObjectType()
|
||||
export class GetTestApiResult {
|
||||
constructor(apiVersion: string) {
|
||||
this.api = `test ${apiVersion}`
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
api: string
|
||||
}
|
||||
|
||||
export class TestResolver {
|
||||
@Query(() => GetTestApiResult)
|
||||
async test(): Promise<String> {
|
||||
logger.info(`test apiVersion=1_1`)
|
||||
return 'test 1_1'
|
||||
const api = `1_0`
|
||||
logger.info(`test apiVersion=1_0`)
|
||||
return new GetTestApiResult(api)
|
||||
}
|
||||
}
|
||||
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const test = gql`
|
||||
query {
|
||||
test {
|
||||
api
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@ObjectType()
|
||||
class GetTestApiResult {
|
||||
constructor(apiVersion: string) {
|
||||
this.api = `test ${apiVersion}`
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
api: string
|
||||
}
|
||||
|
||||
@Resolver()
|
||||
export class TestResolver {
|
||||
@Query(() => GetTestApiResult)
|
||||
async test(): Promise<GetTestApiResult> {
|
||||
logger.info(`test api 1_1`)
|
||||
return new GetTestApiResult("1_1")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,56 @@
|
||||
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
/*
|
||||
|
||||
@ObjectType()
|
||||
export class GetTestApiResult {
|
||||
constructor(apiVersion: string) {
|
||||
this.api = `test ${apiVersion}`
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
api: string
|
||||
}
|
||||
|
||||
export class TestResolver {
|
||||
@Query(() => GetTestApiResult)
|
||||
async test(): Promise<String> {
|
||||
logger.info(`test apiVersion=2_0`)
|
||||
return 'test 2_0'
|
||||
const api = `1_0`
|
||||
logger.info(`test apiVersion=1_0`)
|
||||
return new GetTestApiResult(api)
|
||||
}
|
||||
}
|
||||
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const test = gql`
|
||||
query {
|
||||
test {
|
||||
api
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@ObjectType()
|
||||
class GetTestApiResult {
|
||||
constructor(apiVersion: string) {
|
||||
this.api = `test ${apiVersion}`
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
api: string
|
||||
}
|
||||
|
||||
@Resolver()
|
||||
export class TestResolver {
|
||||
@Query(() => GetTestApiResult)
|
||||
async test(): Promise<GetTestApiResult> {
|
||||
logger.info(`test api 2_0`)
|
||||
return new GetTestApiResult("2_0")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
import path from 'path'
|
||||
// config
|
||||
import CONFIG from '../../config'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
export const getApiResolvers = (apiVersion: String) => {
|
||||
return path.join(__dirname, `./${apiVersion}/resolver/*Resolver.{ts,js}`)
|
||||
export const getApiResolvers = () => {
|
||||
logger.info(`getApiResolvers...${CONFIG.FEDERATION_API}`)
|
||||
return path.join(__dirname, `./${CONFIG.FEDERATION_API}/resolver/*Resolver.{ts,js}`)
|
||||
}
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
import { GraphQLSchema } from 'graphql'
|
||||
import { buildSchema } from 'type-graphql'
|
||||
import path from 'path'
|
||||
|
||||
import isAuthorized from './directive/isAuthorized'
|
||||
import DecimalScalar from './scalar/Decimal'
|
||||
import Decimal from 'decimal.js-light'
|
||||
import { getApiResolvers } from './api/schema'
|
||||
|
||||
const schema = async (apiVersion: String): Promise<GraphQLSchema> => {
|
||||
return buildSchema({
|
||||
resolvers: [getApiResolvers(apiVersion)],
|
||||
const schema = async (): Promise<GraphQLSchema> => {
|
||||
return await buildSchema({
|
||||
resolvers: [getApiResolvers()],
|
||||
authChecker: isAuthorized,
|
||||
scalarsMap: [{ type: Decimal, scalar: DecimalScalar }],
|
||||
})
|
||||
|
||||
@ -7,13 +7,12 @@ import { startDHT } from '@/dht_node/index'
|
||||
import CONFIG from './config'
|
||||
|
||||
async function main() {
|
||||
// TODO better to use yargs than this fix cli-patter -port 5000 -api 1_0
|
||||
const myArgs = process.argv.slice(2)
|
||||
const port = myArgs[0] === '-port' ? myArgs[1] : CONFIG.PORT
|
||||
const apiVersion = myArgs[2] === '-api' ? myArgs[3] : '1_0'
|
||||
// in case of active DHT running on port 5000 else running on (default=5001) CONFIG.FEDERATION_PORT
|
||||
const port = CONFIG.FEDERATION_DHT_TOPIC ? 5000 : CONFIG.FEDERATION_PORT
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`configured: FEDERATION_DHT_TOPIC=${CONFIG.FEDERATION_DHT_TOPIC}, FEDERATION_PORT=${CONFIG.FEDERATION_PORT} => port=${port}`)
|
||||
const { app } = await createServer()
|
||||
|
||||
const { app } = await createServer(apiVersion)
|
||||
|
||||
app.listen(port, () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Server is running at http://localhost:${port}`)
|
||||
|
||||
@ -34,7 +34,6 @@ import { i18n } from './localization'
|
||||
type ServerDef = { apollo: ApolloServer; app: Express; con: Connection }
|
||||
|
||||
const createServer = async (
|
||||
apiVersion: String,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// context: any = serverContext,
|
||||
logger: Logger = apolloLogger,
|
||||
@ -76,9 +75,9 @@ const createServer = async (
|
||||
|
||||
// Apollo Server
|
||||
const apollo = new ApolloServer({
|
||||
schema: await schema(apiVersion),
|
||||
schema: await schema(),
|
||||
// playground: CONFIG.GRAPHIQL,
|
||||
introspection: CONFIG.GRAPHIQL,
|
||||
// introspection: CONFIG.GRAPHIQL,
|
||||
// context,
|
||||
// plugins,
|
||||
logger,
|
||||
|
||||
1165
federation/yarn.lock
1165
federation/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user