Skip to main content
Version: v0.14
info

This module is responsible for exposing application-level APIs.
Check out the Administrative APIs section for information on administration-level requests.

Router

This module provides a way for modules to register application routes for REST and GraphQL APIs.
Endpoint documentation is automatically generated so as to further facilitate development.
It also provides support for application-level WebSockets.

Just like mostly every other router out there, it does so by relying on three key concepts:

  • Input Types
  • Return Types
  • Functional Handlers

Features

  • REST API (based on Express)
  • GraphQL API
  • WebSockets
  • Generated Documentation for REST with OpenAPI & Swagger
  • Generated Documentation for GraphQL with built-in "description" functionality
  • Parameter Validation
  • Custom Middleware

Minimum Configuration

This module requires no configuration.

Environmental Variables

NameRequiredDescriptionExample
CONDUIT_SERVERTrueConduit Core's address and port0.0.0.0:55152
SERVICE_IPTrueAddress and port to listen to for this module0.0.0.0:56154
REGISTER_NAMEFalseName-based network registration (containers)False
CLIENT_HTTP_PORTFalsePort to be used by admin REST and GraphQL APIs3000
CLIENT_SOCKET_PORTFalsePort to be used by admin WebSocket API3001
GRCP_KEYFalseSpecifying a secret enables gRPC signed request protectionsomeRandomSecret

Registering Routes

So how does one register their routes?
Before we elaborate on that, you should first consider the following:

Do I really need custom routes?

Modules automatically handle registering their routes for you.
Therefore, as long as you don't need additional functionality, you don't really need to worry about doing any of that yourself.
Routes are automatically registered or recovered upon bringing up a module, so make sure you start any of the modules you wish to experiment with before checking out Swagger or sending out any requests to these modules.

If you're simply trying to create CRUD endpoints for your database schemas, the answer is most likely "No".
The Database module already covers that use case as custom schemas enabling CRUD operations already come with auto-generated CRUD routes.
It also supports the creation of code-free custom endpoints for your schemas.
You can even accomplish that graphically through the Database section of the Admin Panel too!

I'm fairly sure I do

If you really need to write your own routes from the ground up, you're going to have to build your own custom modules.