DEV Community

Cover image for ExpressoTS 2.6.0 is Out!
Richard Zampieri for ExpressoTS

Posted on

ExpressoTS 2.6.0 is Out!

New Features in ExpressoTS: Boosting Backend Development!

We're thrilled to introduce the latest features in ExpressoTS designed to accelerate your backend development. Dive in to explore what we have in store for you:

Consider giving our project a star on GitHub ExpressoTS! It'll help increase our visibility and support our efforts. ๐ŸŒŸ Thanks in advance!

๐Ÿš€ Non-Opinionated Template

  1. Simplified Middleware Passing Pass middleware with ease in the AppFactory.create() method:
async function bootstrap() {
  const app = await AppFactory.create(container, [cors(), helmet()]);
  await app.listen(3000, ServerEnvironment.Development);
}
Enter fullscreen mode Exit fullscreen mode
  1. Setting Node Environment Automatically set your Node environment just by selecting an enum option:
  2. Development
  3. Production
await app.listen(3000, ServerEnvironment.Development);
Enter fullscreen mode Exit fullscreen mode
  1. Direct Access to Expressjs Object
    Configure and set up your application directly with the ExpressApp object.

  2. Global Route Prefix
    Easily set the global prefix during your application's bootstrap phase:

app.setGlobalRoutePrefix("/api");
Enter fullscreen mode Exit fullscreen mode

๐Ÿ† Opinionated Template

The App class provider is the cornerstone of the opinionated template. From initialization to server bootstrap configuration, it covers it all:

class App extends AppExpress {
  private middleware: IMiddleware;
  private provider: IProvider;

  constructor() {
    super();
    this.middleware = container.get<IMiddleware>(Middleware);
    this.provider = container.get<IProvider>(Provider);
  }

  protected configureServices(): void {
    this.middleware.addBodyParser();
    this.middleware.setErrorHandler();
  }

  protected postServerInitialization(): void {
    if (this.isDevelopment()) {
      this.provider.envValidator.checkAll();
    }
  }

  protected serverShutdown(): void {}
}
Enter fullscreen mode Exit fullscreen mode

Key Highlights:

  • Out-of-the-box Middlewares: Here is a list of currently available middlewares out-of-the-box:

Middlewares Available

  • Global Route Prefix: Set your global prefix seamlessly.
  • Utility isDevelopment Method: A convenient way to perform operations based on your environment:
class App extends AppExpress {
  private middleware: IMiddleware;
  private provider: IProvider;

  constructor() {
    super();
    this.middleware = container.get<IMiddleware>(Middleware);
    this.provider = container.get<IProvider>(Provider);
  }

  protected configureServices(): void {
    this.setGlobalRoutePrefix("/api"); // Global prefix
    this.middleware.addBodyParser();
    this.middleware.setErrorHandler();
  }

  protected postServerInitialization(): void {
    if (this.isDevelopment()) { // isDevelopment method
      this.provider.envValidator.checkAll();
    }
  }

  protected serverShutdown(): void {}
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“– Code by Example

Want hands-on experience with ExpressoTS features? We've dedicated a whole section to coding examples in our documentation. Ease your search and coding journey with us. Dive in here ...

๐Ÿ“ฆ Performance Enhancements

We're also excited to announce a 50% reduction in our library bundle size, ensuring a smoother and faster experience for all!

Top comments (2)

Collapse
 
ben profile image
Ben Halpern

Congrats!

Collapse
 
rsaz profile image
Richard Zampieri

Thank you!