Modules
The most basic pieces of Entropy apps are modules. Module is a simple chunk of code in a separate directory in the src/ folder. Each module should have a corresponding .module.ts file and represent single app feature part.
Creating a Module
To create a new module, you can leverage the CLI:
terminal
entropy make module chat
Module Structure
Each feature module file has a similar structure:
src/chats/chat.controller.ts
import { Module } from '@entropy/server';
import { ChatChannel } from './chat.channel.ts';
import { ChatController } from './chat.controller.ts';
export class ChatModule implements Module {
public readonly channels = [
ChatChannel,
];
public readonly controllers = [
ChatController,
];
}
Registering Modules
Every module should be registered in the src/main.ts file in modules section like so:
src/main.ts
import { createServer } from '@entropy/server';
import { RootModule } from './root.module.ts';
if (import.meta.main) {
const server = await createServer({
modules: [RootModule],
});
await server.start();
}