https://github.com/fuma-nama/discord-dashboard-backend-next
https://github.com/fuma-nama/discord-dashboard-backend-next
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fuma-nama/discord-dashboard-backend-next
- Owner: fuma-nama
- Archived: true
- Created: 2023-03-05T13:44:39.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-05T10:55:19.000Z (over 1 year ago)
- Last Synced: 2025-01-26T20:08:07.132Z (9 months ago)
- Language: TypeScript
- Size: 129 KB
- Stars: 22
- Watchers: 1
- Forks: 13
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[Go to Frontend](https://github.com/SonMooSans/discord-bot-dashboard-next)
# Discord Bot Dashboard Backend Demo
## Tech Stack
- Database (Prisma)
- Nest.js with Typescript
- Discord.js
- PnPM (Package Manager)## Install Dependencies
Make sure you're using [pnpm](https://pnpm.io), in order to load the lock file
```
pnpm install
```## Environment variables
You need some **Environment variables** in order to run it
### Database url
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"`
### Discord Bot Token
The bot token is also required
`BOT_TOKEN="YOUR_TOKEN"`
### Web URL
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
## Create Prisma Migrate baseline
You need to create a migration baseline before deploying your app
1. **Reset Development database**
```
prisma migrate dev
```2. **Production database**
```
prisma migrate resolve --applied 20230305142521_initial
```[Learn More](https://pris.ly/d/migrate-baseline)
## Deploy
We recommend using https://railway.app to deploy your backend
You are able to host both your database and node.js server on Railway
## File Structure
| Path | Description |
| ----------------------- | ------------------ |
| `./src/bot` | The Discord bot |
| `./src/api` | The API service |
| `./src/api/controllers` | API controllers |
| `./src/api/services` | 3rd party services |### Add a Feature
Create new routes in the guild controller
[Learn More](https://github.com/SonMooSans/discord-bot-dashboard-next#required-routes)
```ts
@Get('/features/welcome-message')
async getWelcomeMessage(@Param('guild') guild: string) {
//Database callsreturn {
message: 'message',
channel: '1111',
};
}@Post('/features/welcome-message')
async enableWelcomeMessage(@Req() req: AuthRequest, @Param('guild') guild: string) {
//Enables the featurereturn 'Success';
}@Patch('/features/welcome-message')
async updateWelcomeMessage(
@Req() req: AuthRequest,
@Param('guild') guild: string,
@Body() body: Partial,
) {
//Update the featurereturn updated;
}@Delete('/features/welcome-message')
async disableWelcomeMessage(@Param('guild') guild: string, @Req() req: AuthRequest) {
//Disables the featurereturn 'Success';
}
```