ExpressWebJs 3.2 Released

chukwuemekaigbokwe

Chukwuemeka Igbokwe

Posted on September 19, 2021

ExpressWebJs 3.2 Released

The ExpressWebJs team have released 3.2 with auto endpoint documentation, and improvement in service injection.

Auto Endpoint Documentation:

Reference documentation for API endpoints consists of five general sections: resource descriptions, endpoints and methods, parameters, sample requests, and sample responses and schemas. All these are auto documented for you while you code, to allow you focus on building your amazing application.

To get started, install ExpressWebJs by running the command below

 npx expresswebcli new MyApplication --ts
Enter fullscreen mode Exit fullscreen mode

and run 'npm install' to install the node packages 📦. Then create few endpoints and visit your base url in a browser followed by /documentationView for HTML view or /documentationJson for JSON.

Example: http://127.0.0.1:5000/documentationView or http://127.0.0.1:5000/documentationJson.

Service Injection

You can now inject services irrespective of the order in the application context.

In our Application Service Provider register method, we've registered some services.


  public register() {
    this.app.singleton("UserService", UserService, "class");
    this.app.singleton("CompanyService", CompanyService, "class");
    this.app.singleton("FolderService", FolderService, "class");
  }

Enter fullscreen mode Exit fullscreen mode

Now we can inject UserService into FolderService like so:


import FolderRepository from "App/Repository/FolderRepository";
import BaseService from "../BaseService";
import IFolderService from "./IFolderService";
import IUserService from "./IUserService";

class FolderService extends BaseService implements
  protected userService:IUserService

  constructor(UserService:IUserService){
    this.userService = UserService
  }

 IFolderService {
  async getSubFolders(user_id: string): Promise<object> {
    return await new Promise(async (resolve, reject) => {
      try {
        let data = await new userService().findById(user_id);
        ...
      } catch (error: any) {
        ...
      }
    });
  }
}

Enter fullscreen mode Exit fullscreen mode

You can join ExpressWebJs community on Discord and don't forget to give us a star on github
ExpressWebJs Javascript and ExpressWebJs Typescript

💖 💪 🙅 🚩
chukwuemekaigbokwe
Chukwuemeka Igbokwe

Posted on September 19, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ExpressWebJs 3.2 Released
expresswebjs ExpressWebJs 3.2 Released

September 19, 2021