SFrontendServer modules

The SFrontendServer is based on the AMAZING ExpressJs server. This mean that you can extend it as you want by following these steps described bellow:

Built-in modules

Our server comes with some built-in modules. Here's the list:

  • 404: This module handle the 404 by rendering either your 404 page configured in the pages or the default 404 page

  • publicDir: This module allows you to serve files from the public directory

  • upload: This module allows you to upload files to the tmp/upload directory

  • generic: This module gives you access to the "generic" handler that renders dynamically views from your page config

  • docmap: This module gives you access to a "docmap" object in the views

  • classmap: This module gives you access to the /classmap.json url

  • carpenter: This module gives you access to a "carpenter" object in the views

  • redirect: This module allows you to make redirections depending on requested path

  • config: This module gives you access to a "config" and a "configFiles" object into the views

  • frontspec: This module gives you access to a "frontspec" object into the views

Create your module

First of all, create a file (where you want) src/node/myModule.ts that will be the entry point of your module.

Here's the scaffold content that you can copy and past in your file:

You module default exported function will be called with an object containing these data:

  • express: The express instance used for the server on which you can register new routes, etc...
  • settings: The settings object specified in the frontendServer.config.ts file alongside your module path.
  • config: The full frontendServer.config.ts configuration object.
  • startParams: The parameters passed to the SFrontendServer.start method.

Register your module

To to register your module, simply add it to the config.frontendServer.modules by creating a file under .sugar/frontendServer.config.ts like this:

For more information about configuring your server, check out the next doc that talk about handlers, middleware and routes.

Bugs
are not our friends...

Don't hesitate to declare an issue if something does not works as expected.

Declare my issue on Github Talk about it on Discord

The more we are,
the stronger we become.

Don't hesitate to tell some words to you friends about us. The goal is to became more and more each days to help each others...

Support us on Patreon! Share on Facebook! Make a tweet!

The more we are,
the stronger we become.

Don't be afraid to join us on Discord.

Join us on discord!

We love,
Open source!

All of our codebase can be found on Github. We hope that you may contribute to help us make our tools even better!

Discover our codebase!

Welcome on