1800dbbdbd
* userProjectsUpdated.added test * multi region support * userStreamAdded * commit subs tested * fix for proj workspace assignment * undo commitHelper main changes * disable all ffs mode * createTestWorkspace support when workspaces arent enabled * project create fix * workspace projects updated subscription * WIP new workspace sub * updated workspaceCreated * updated workspaceUpdated * BE for workspace updated sub * workspace updated sub * ts err fix
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import { moduleLogger } from '@/logging/logging'
|
|
import {
|
|
setupResultListener,
|
|
shutdownResultListener
|
|
} from '@/modules/core/utils/dbNotificationListener'
|
|
import * as mp from '@/modules/shared/utils/mixpanel'
|
|
import { SpeckleModule } from '@/modules/shared/helpers/typeHelper'
|
|
|
|
import staticRest from '@/modules/core/rest/static'
|
|
import uploadRest from '@/modules/core/rest/upload'
|
|
import downloadRest from '@/modules/core/rest/download'
|
|
import diffUpload from '@/modules/core/rest/diffUpload'
|
|
import diffDownload from '@/modules/core/rest/diffDownload'
|
|
import scopes from '@/modules/core/scopes'
|
|
import roles from '@/modules/core/roles'
|
|
import { getGenericRedis } from '@/modules/shared/redis/redis'
|
|
import { registerOrUpdateScopeFactory } from '@/modules/shared/repositories/scopes'
|
|
import db from '@/db/knex'
|
|
import { registerOrUpdateRole } from '@/modules/shared/repositories/roles'
|
|
import { isTestEnv } from '@/modules/shared/helpers/envHelper'
|
|
|
|
let stopTestSubs: (() => void) | undefined = undefined
|
|
|
|
const coreModule: SpeckleModule = {
|
|
async init(app, isInitial) {
|
|
moduleLogger.info('💥 Init core module')
|
|
|
|
// Initialize the static route
|
|
staticRest(app)
|
|
|
|
// Initialises the two main bulk upload/download endpoints
|
|
uploadRest(app)
|
|
downloadRest(app)
|
|
|
|
// Initialises the two diff-based upload/download endpoints
|
|
diffUpload(app)
|
|
diffDownload(app)
|
|
|
|
const scopeRegisterFunc = registerOrUpdateScopeFactory({ db })
|
|
// Register core-based scoeps
|
|
for (const scope of scopes) {
|
|
await scopeRegisterFunc({ scope })
|
|
}
|
|
|
|
const roleRegisterFunc = registerOrUpdateRole({ db })
|
|
// Register core-based roles
|
|
for (const role of roles) {
|
|
await roleRegisterFunc({ role })
|
|
}
|
|
|
|
if (isInitial) {
|
|
// Setup global pg notification listener
|
|
setupResultListener()
|
|
|
|
// Init mp
|
|
mp.initialize()
|
|
|
|
// Setup test subs
|
|
if (isTestEnv()) {
|
|
const { startEmittingTestSubs } = await import('@/test/graphqlHelper')
|
|
stopTestSubs = await startEmittingTestSubs()
|
|
}
|
|
}
|
|
},
|
|
async shutdown() {
|
|
await shutdownResultListener()
|
|
await getGenericRedis().quit()
|
|
stopTestSubs?.()
|
|
}
|
|
}
|
|
|
|
export = coreModule
|