Category : koa2

I have the following code… const auth = new Authentication(); mainApp.use(auth.checkToken.bind(auth)); mainApp.use(mount(‘/auth’, auth.app)); class Authentication{ constructor() { this.redirectApp = new Koa(); this.redirectApp.use(this.onLogin); this.logoutApp = new Koa(); this.logoutApp.use(this.onLogout); this.callbackApp = new Koa(); this.callbackApp.use(this.onCallback); this.app = new Koa(); this.app.use(mount(‘/login’, this.redirectApp)); this.app.use(mount(‘/callback’, this.callbackApp)); this.app.use(mount(‘/logout’, this.logoutApp)); } checkToken(ctx, next){ if(ctx.path === "/auth/login" || ctx.path === "/auth/callback" || ctx.path === ..

Read more

as mentioned in the topic, I cannot only get undefined back from my api server when I trying to test it with mocha and chai, the framework for API is koa2. Please see codes attached Testfile var chai = require(‘chai’); var chaiHttp = require(‘chai-http’); chai.use(chaiHttp); const app = require(‘../app’) const expect = chai.expect describe( ‘stat ..

Read more

I’m developing backend application in typescript. I want to define shape of an object. From typescript, I have options like classes, interfaces, types. Which one should I use? Below are the docs recommending interfaces to define shapes. https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html, The below document says, its better to use interface on types https://www.typescriptlang.org/play?e=83#example/types-vs-interfaces they recommend using interfaces to ..

Read more