Describe the bug
It seems bottender has a hardwired path expecting an index.js in the same directory as you run the server.
I'm moving a project to typescript so the raw source is under src and I usually run in dev with ts-node
➜ server git:(move-to-ts) ✗ ts-node src/server.js
Error: Cannot find module '/Users/dc/dev/exiteer/xbot/server/index.js'
Require stack:
- /Users/dc/dev/exiteer/xbot/server/node_modules/bottender/dist/server/Server.js
- /Users/dc/dev/exiteer/xbot/server/node_modules/bottender/dist/bottender.js
- /Users/dc/dev/exiteer/xbot/server/node_modules/bottender/dist/index.js
- /Users/dc/dev/exiteer/xbot/server/src/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at DevServer.<anonymous> (/Users/dc/dev/exiteer/xbot/server/node_modules/bottender/src/server/Server.ts:51:37)
at Generator.next (<anonymous>)
at /Users/dc/dev/exiteer/xbot/server/node_modules/bottender/dist/server/Server.js:8:71
at new Promise (<anonymous>)
at __awaiter (/Users/dc/dev/exiteer/xbot/server/node_modules/bottender/dist/server/Server.js:4:12)
at DevServer.prepare (/Users/dc/dev/exiteer/xbot/server/node_modules/bottender/dist/server/Server.js:47:16)
I'm wondering if there's a way to pass the routes file to botTender explicitly when starting up?
src/server.js
const bot = bottender({
dev: process.env.NODE_ENV !== 'production',
});
// the request handler of the bottender app
const handle = bot.getRequestHandler();
bot.prepare().then(() => {
const server = express();
botRouter.js
const { router, text, slack } = require('bottender/router')
const Dispatcher = require('./mup/Dispatcher')
const botRoutes = async function App () {
// Logger.log('init routes game', game)
const routes = router([
text(/^e$|^echo$/i, Dispatcher.echo),
I'm not quite sure how to wire those things together, there seems to be some lazy loading going on with the routing currently.
Expected behavior
A more explicit way to startup a project, less magic requires happening behind the scenes...
This is mainly to support a project in typescript
Describe the bug
It seems bottender has a hardwired path expecting an
index.jsin the same directory as you run the server.I'm moving a project to typescript so the raw source is under
srcand I usually run in dev withts-nodeI'm wondering if there's a way to pass the routes file to botTender explicitly when starting up?
I'm not quite sure how to wire those things together, there seems to be some lazy loading going on with the routing currently.
Expected behavior
A more explicit way to startup a project, less magic requires happening behind the scenes...
This is mainly to support a project in typescript