Add notifications module

This commit is contained in:
Barry Low committed 2018-12-14 19:42:57 -08:00
1 parent 353aee8b0a
commit 610cdef115
2 files changed
+39 -6

No files matched your search

+6 -1
View File
@@ -7,13 +7,18 @@ KEYVAULT_API_PRESHARED=THIS_IS_VERY_SECRET
FINANCIAL_BEINGS_API_PRESHARED=THIS_IS_VERY_SECRET
NOTIFICATIONS_API_PRESHARED=THIS_IS_VERY_SECRET
# PROJECT_SITE_URL=https://advancedalgos.net
PROJECT_SITE_URL=http://localhost:3999
# PLATFORM_URL=https://platform.advancedalgos.net
PLATFORM_URL=http://localhost:3100
GRAPHQL_API_URL=https://platform-api-dev.advancedalgos.net/graphql
TEAMS_API_URL=https://teams-api-dev.advancedalgos.net/graphql
USERS_API_URL=https://users-api-dev.advancedalgos.net/graphql
EVENTS_API_URL=https://events-api-dev.advancedalgos.net/graphql
KEYVAULT_API_URL=https://keyvault-api-dev.advancedalgos.net/graphql
FINANCIAL_BEINGS_API_URL=https://financialbeings-api-dev.advancedalgos.net/graphql
NOTIFICATIONS_API__URL=https://notifications-api-dev.advancedalgos.net/graphql
NOTIFICATIONS_API_URL=https://notifications-api-dev.advancedalgos.net/graphql
AUTH0_DOMAIN=auth0-domain
AUTH0_AUDIENCE=auth0-audience
+33 -5
View File
@@ -68,7 +68,12 @@ async function run () {
'financialBeings_',
process.env.FINANCIAL_BEINGS_API_URL,
process.env.FINANCIAL_BEINGS_API_PRESHARED)
logger.info('FINANCIAL_BEINGS schema created')
logger.info('Financial Beings schema created')
const transformedNotificationsSchema = await createTransformedRemoteSchema(
'notifications_',
process.env.NOTIFICATIONS_API_URL,
process.env.NOTIFICATIONS_API_PRESHARED)
logger.info('Notifications schema created')
var schemas = [masterSchema]
var resolvers = {}
@@ -97,7 +102,10 @@ async function run () {
if (transformedFinancialBeingsSchema) {
schemas.push(transformedFinancialBeingsSchema)
}
if (transformedNotificationsSchema) {
schemas.push(transformedNotificationsSchema)
}
const schema = mergeSchemas({
schemas,
resolvers
@@ -164,7 +172,7 @@ async function run () {
return error
},
formatResponse: response => {
logger.debug('Response from Apolo Server: ' + response)
logger.debug('Response from Apollo Server: ' + response)
return response
},
playground: {
@@ -175,9 +183,29 @@ async function run () {
}
})
server.applyMiddleware({ app })
const whitelist = [
process.env.PROJECT_SITE_URL,
process.env.PLATFORM_URL,
process.env.GRAPHQL_API_URL,
process.env.TEAMS_API_URL,
process.env.USERS_API_URL,
process.env.EVENTS_API_URL,
process.env.KEYVAULT_API_URL,
process.env.FINANCIAL_BEINGS_API_URL,
process.env.NOTIFICATIONS_API_URL
]
app.use(cors())
const corsOptionsDelegate = (req, callback) => {
let corsOptions
if (whitelist.indexOf(req.header('Origin')) !== -1) {
corsOptions = { origin: true, credentials: true }
} else {
corsOptions = { origin: false, credentials: true }
}
callback(null, corsOptions)
}
server.applyMiddleware({ app, cors: corsOptionsDelegate })
app.listen(4100)
logger.info(`Server running. Open ${process.env.GRAPHQL_API_URL} to run queries.`)