javascript - Calling an ES6 class middleware using KOA -


i have function in es6 class i'm trying call middleware no success. in index file, have:

*i have included relevant code

"use strict";     const http        = require('http')     const koa         = require('koa')     const app         = new koa()     const bodyparser  = require('koa-better-body')     const install     = require('./.system/install/install')        const install     = new install()  class index {   /**   * class constructor function   * @class index   * @method constructor   * @return {undefined}   */   constructor () {   }    /**   * main entry method    * @class index   * @method init async   * @return {undefined}   */   async init(){     // install helper     app.use(install.setup)      // response     app.use(async ctx => {       ctx.body = 'hello world';     });      http.createserver(app.callback()).listen(8080);   } }  let init = new index(); init.init() 

and in install.js, have:

       "use strict";         const process = require('./library/process')         const fs      = require('async-file')      module.exports = class install {         async setup (ctx, next) {              ctx.body = 'install';         }     } 

but koa app keeps giving me 404 not found error. know static method might solve i'd rather not use static methods. install class has both middleware function , standard functions.

you have 404, because don't use koa-router


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -