ed458fb619
* feat(server): add server authz pipeline rework first sketch * feat(server authz): add new server authz middleware poc implementation * test(server authz): add unittests for the new server authz workflow * feat(wip rework of fileuploads vs blob storage): add basim impl of separate blob storage service * feat(fileimport service): refactored file import service to utilize the new asssetstorage service * refactor(server errors): refactor server errors to use the shared module definitions Now all the errors inherit from BaseError * refactor(fileimport service): cleanup after refactor * feat(frontend fileimports): use the new blob storage for downloading the original file * refactor(server fileimports): clean up the remnants of S3 storage from file imports * refactor(server authz): centralize generic authz pipeline configs * refactor(server blob storage): refactor / rename everything to use the `blob-storage` name * ci(circleci): add s3 objectstorage environment variables * ci(circleci): fix missing env variables * ci(circleci): add minio test container * ci(circleci): fix minio app startup * ci(circleci): enable circleci remote docker * ci(circleci): fix minio startup * ci(cirleci): detach and wait properly for minio to start * ci(circleci): revert to additional minio img config, it only fails when the container is stopped ?! * ci(circleci): disable file uploads * fix(fileimports): update with blob storage refactor leftovers * feat(server blob storage): add blob storage graphql api * refactor(server errors): merge new errors to shared module * fix(server comments rte): fix import for RTE error * chore(fileimports): remove node-fetch from dependency * chore(server): remove body parser dependency * fix(server blob storage): fix gql api * fix(frontend): fix fileupload item not loading the new upload status, cause of premature event fire * feat(server blob storage): fix file size limit and allow for public streams * Update packages/server/modules/blobstorage/graph/schemas/blobstorage.graphql Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com> * chore(blobstorage): fix PR review issues * fix(server): fix import bugs Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
103 lines
2.5 KiB
JavaScript
103 lines
2.5 KiB
JavaScript
'use strict'
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
const { appRoot } = require('@/bootstrap')
|
|
const autoload = require('auto-load')
|
|
const { values, merge } = require('lodash')
|
|
const { scalarResolvers, scalarSchemas } = require('./core/graph/scalars')
|
|
|
|
exports.init = async (app) => {
|
|
const moduleDirs = [
|
|
'./core',
|
|
'./auth',
|
|
'./apiexplorer',
|
|
'./emails',
|
|
'./pwdreset',
|
|
'./serverinvites',
|
|
'./previews',
|
|
'./fileuploads',
|
|
'./comments',
|
|
'./blobstorage'
|
|
]
|
|
|
|
// Stage 1: initialise all modules
|
|
for (const dir of moduleDirs) {
|
|
await require(dir).init(app)
|
|
}
|
|
|
|
// Stage 2: finalize init all modules
|
|
for (const dir of moduleDirs) {
|
|
await require(dir).finalize(app)
|
|
}
|
|
}
|
|
|
|
exports.graph = () => {
|
|
const dirs = fs.readdirSync(`${appRoot}/modules`)
|
|
// Base query and mutation to allow for type extension by modules.
|
|
const typeDefs = [
|
|
`
|
|
${scalarSchemas}
|
|
directive @hasScope(scope: String!) on FIELD_DEFINITION
|
|
directive @hasScopes(scopes: [String]!) on FIELD_DEFINITION
|
|
directive @hasRole(role: String!) on FIELD_DEFINITION
|
|
|
|
type Query {
|
|
"""
|
|
Stare into the void.
|
|
"""
|
|
_: String
|
|
}
|
|
type Mutation{
|
|
"""
|
|
The void stares back.
|
|
"""
|
|
_: String
|
|
}
|
|
type Subscription{
|
|
"""
|
|
It's lonely in the void.
|
|
"""
|
|
_: String
|
|
}`
|
|
]
|
|
|
|
let resolverObjs = []
|
|
let schemaDirectives = {}
|
|
|
|
dirs.forEach((file) => {
|
|
const fullPath = path.join(`${appRoot}/modules`, file)
|
|
|
|
// load and merge the type definitions
|
|
if (fs.existsSync(path.join(fullPath, 'graph', 'schemas'))) {
|
|
const moduleSchemas = fs.readdirSync(path.join(fullPath, 'graph', 'schemas'))
|
|
moduleSchemas.forEach((schema) => {
|
|
typeDefs.push(
|
|
fs.readFileSync(path.join(fullPath, 'graph', 'schemas', schema), 'utf8')
|
|
)
|
|
})
|
|
}
|
|
|
|
// first pass load of resolvers
|
|
if (fs.existsSync(path.join(fullPath, 'graph', 'resolvers'))) {
|
|
resolverObjs = [
|
|
...resolverObjs,
|
|
...values(autoload(path.join(fullPath, 'graph', 'resolvers')))
|
|
]
|
|
}
|
|
|
|
// load directives
|
|
if (fs.existsSync(path.join(fullPath, 'graph', 'directives'))) {
|
|
schemaDirectives = Object.assign(
|
|
...values(autoload(path.join(fullPath, 'graph', 'directives')))
|
|
)
|
|
}
|
|
})
|
|
|
|
const resolvers = { ...scalarResolvers }
|
|
resolverObjs.forEach((o) => {
|
|
merge(resolvers, o)
|
|
})
|
|
|
|
return { resolvers, typeDefs, schemaDirectives }
|
|
}
|