Skip to content

Commit

Permalink
fix(modules): fixed module entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy committed Oct 4, 2019
1 parent 1a80438 commit a872630
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 25 deletions.
3 changes: 0 additions & 3 deletions modules/basic-skills/src/backend/index.ts
Expand Up @@ -7,8 +7,6 @@ import choice from './choice'
import email from './email'
import slot from './slot'

const onServerStarted = async (bp: typeof sdk) => {}

const onServerReady = async (bp: typeof sdk) => {
await choice.setup(bp)
}
Expand Down Expand Up @@ -45,7 +43,6 @@ const skillsToRegister: sdk.Skill[] = [
]

const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
onModuleUnmount,
definition: {
Expand Down
5 changes: 0 additions & 5 deletions modules/builtin/src/backend/index.ts
@@ -1,17 +1,12 @@
import * as sdk from 'botpress/sdk'

const onServerStarted = async (bp: typeof sdk) => {}
const onServerReady = async (bp: typeof sdk) => {}

const botTemplates: sdk.BotTemplate[] = [
{ id: 'welcome-bot', name: 'Welcome Bot', desc: `Basic bot that showcases some of the bot's functionality` },
{ id: 'small-talk', name: 'Small Talk', desc: `Includes basic smalltalk examples` },
{ id: 'empty-bot', name: 'Empty Bot', desc: `Start fresh with a clean flow` }
]

const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
botTemplates,
definition: {
name: 'builtin',
Expand Down
3 changes: 0 additions & 3 deletions modules/channel-messenger/src/backend/index.ts
Expand Up @@ -14,8 +14,6 @@ const onServerStarted = async (bp: typeof sdk) => {
}
}

const onServerReady = (bp: typeof sdk) => {}

const onBotMount = async (bp: typeof sdk, botId: string) => {
await service.mountBot(botId)
}
Expand All @@ -30,7 +28,6 @@ const onModuleUnmount = async (bp: typeof sdk) => {
}

const entryPoint: sdk.ModuleEntryPoint = {
onServerReady,
onServerStarted,
onBotMount,
onBotUnmount,
Expand Down
3 changes: 0 additions & 3 deletions modules/channel-web/src/backend/index.ts
Expand Up @@ -13,16 +13,13 @@ const onServerStarted = async (bp: typeof sdk) => {
await socket(bp, db)
}

const onServerReady = async (bp: typeof sdk) => {}

const onModuleUnmount = async (bp: typeof sdk) => {
bp.events.removeMiddleware('web.sendMessages')
bp.http.deleteRouterForBot('channel-web')
}

const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
onModuleUnmount,
definition: {
name: 'channel-web',
Expand Down
2 changes: 0 additions & 2 deletions modules/code-editor/src/backend/index.ts
Expand Up @@ -8,7 +8,6 @@ import { EditorByBot } from './typings'

const editorByBot: EditorByBot = {}

const onServerStarted = async (bp: typeof sdk) => {}
const onServerReady = async (bp: typeof sdk) => {
await api(bp, editorByBot)
}
Expand All @@ -23,7 +22,6 @@ const onBotUnmount = async (bp: typeof sdk, botId: string) => {
}

const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
onBotMount,
onBotUnmount,
Expand Down
2 changes: 0 additions & 2 deletions modules/extensions/src/backend/index.ts
@@ -1,6 +1,5 @@
import * as sdk from 'botpress/sdk'

const onServerStarted = async (bp: typeof sdk) => {}
const onServerReady = async (bp: typeof sdk) => {
const router = bp.http.createRouterForBot('extensions')
const config = (await bp.config.getBotpressConfig()).eventCollector
Expand All @@ -24,7 +23,6 @@ const onServerReady = async (bp: typeof sdk) => {
}

const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
definition: {
name: 'extensions',
Expand Down
3 changes: 0 additions & 3 deletions modules/testing/src/backend/index.ts
Expand Up @@ -2,13 +2,11 @@ import * as sdk from 'botpress/sdk'
import _ from 'lodash'

import api from './api'

import { Testing } from './testing'
import { TestByBot } from './typings'

const testByBot: TestByBot = {}

const onServerStarted = async (bp: typeof sdk) => {}
const onServerReady = async (bp: typeof sdk) => {
await api(bp, testByBot)
}
Expand All @@ -26,7 +24,6 @@ const onModuleUnmount = async (bp: typeof sdk) => {
}

const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
onModuleUnmount,
onBotMount,
Expand Down
4 changes: 2 additions & 2 deletions src/bp/core/module-loader.ts
Expand Up @@ -23,8 +23,8 @@ import { ModuleResourceLoader } from './services/module/resources-loader'
import { TYPES } from './types'

const MODULE_SCHEMA = joi.object().keys({
onServerStarted: joi.func().required(),
onServerReady: joi.func().required(),
onServerStarted: joi.func().optional(),
onServerReady: joi.func().optional(),
onBotMount: joi.func().optional(),
onBotUnmount: joi.func().optional(),
onModuleUnmount: joi.func().optional(),
Expand Down
4 changes: 2 additions & 2 deletions src/bp/sdk/botpress.d.ts
Expand Up @@ -86,9 +86,9 @@ declare module 'botpress/sdk' {
/** An array of available bot templates when creating a new bot */
botTemplates?: BotTemplate[]
/** Called once the core is initialized. Usually for middlewares / database init */
onServerStarted: (bp: typeof import('botpress/sdk')) => void
onServerStarted?: (bp: typeof import('botpress/sdk')) => void
/** This is called once all modules are initialized, usually for routing and logic */
onServerReady: (bp: typeof import('botpress/sdk')) => void
onServerReady?: (bp: typeof import('botpress/sdk')) => void
onBotMount?: (bp: typeof import('botpress/sdk'), botId: string) => void
onBotUnmount?: (bp: typeof import('botpress/sdk'), botId: string) => void
/**
Expand Down

0 comments on commit a872630

Please sign in to comment.