- Database (Prisma)
- Nest.js with Typescript
- Discord.js
- PnPM (Package Manager)
Make sure you're using pnpm, in order to load the lock file
pnpm install
You need some Environment variables in order to run it
It is used for Prisma, I am using PostgreSQL but you may use any supported databases as well
DATABASE_URL="postgresql://postgres:password@localhost:5432/my-db?schema=public"
The bot token is also required
BOT_TOKEN="YOUR_TOKEN"
The WEB_URL
is the default origin of the CORS configuration
WEB_URL="https://my-bot.vercel.app"
We will use localhost:3000
in default
You need to create a migration baseline before deploying your app
-
Reset Development database
prisma migrate dev
-
Production database
prisma migrate resolve --applied 20230305142521_initial
We recommend using https://railway.app to deploy your backend
You are able to host both your database and node.js server on Railway
Path | Description |
---|---|
./src/bot |
The Discord bot |
./src/api |
The API service |
./src/api/controllers |
API controllers |
./src/api/services |
3rd party services |
Create new routes in the guild controller
@Get('/features/welcome-message')
async getWelcomeMessage(@Param('guild') guild: string) {
//Database calls
return {
message: 'message',
channel: '1111',
};
}
@Post('/features/welcome-message')
async enableWelcomeMessage(@Req() req: AuthRequest, @Param('guild') guild: string) {
//Enables the feature
return 'Success';
}
@Patch('/features/welcome-message')
async updateWelcomeMessage(
@Req() req: AuthRequest,
@Param('guild') guild: string,
@Body() body: Partial<WelcomeMessage>,
) {
//Update the feature
return updated;
}
@Delete('/features/welcome-message')
async disableWelcomeMessage(@Param('guild') guild: string, @Req() req: AuthRequest) {
//Disables the feature
return 'Success';
}