ExpressJs
The API server preset using ExpressJs comes pre-configured to simplify development. Here's what you need to know to get started:
Knowledge of the ExpressJs framework is essential for optimal use. Read the documentation: https://expressjs.com/
Starting the Server
The file containing the code to start the server is located in src/server/index.ts
. The server will only start after the bot is ready! Therefore, a ready
event from the bot is used to start the server. See:
src/server/index.ts
This way, simply import this file in src/index.ts
and the event will be registered:
src/index.ts
The express server will then start immediately after the bot comes online, thus having Client<true>
(Client instance when already online) to be used in routes.
Environment Variables
The zod schema for validating the env has been changed to allow new environment variables.
src/env.ts
This means you can change the port of the express server using this variable in the .env
file
.env
Cors
In this preset, the cors plugin is already installed and has a basic configuration:
src/server/index.ts
Read the full plugin documentation to understand the best use cases: https://github.com/expressjs/cors