/backend

Primary LanguageTypeScript

chax-backend

Run

Clone the repo and install the packages:

git clone https://github.com/Chaxware/backend.git
cd backend
bun install

Next, setup a database (either local, or in the cloud)

Database (Local)

  • Install the Turso CLI
  • Setup local libsql server, and migrate schema:
turso dev --db-file dev.db
bunx drizzle-kit migrate

Database (Cloud)

To host your own database using turso, go to their website, and create an account. You may create your database during the signup process (name the database chax or something).

Then follow the instructions at the quickstart page (upto 2nd step if you have already made a database). Also follow the first step in the TypeScript section.

Create a .env file in the root directory, and fill it with your URL and token:

DATABASE_URL="<URL (starts with libsql://)>"
DATABASE_TOKEN="<database authentication token>"

Important: You must set the NODE_ENV environment variable to production if you need to use the cloud database.

Bootstrap (optional)

To fill a fresh database with sample data (hubs, channels and messages):

bun bootstrap

Server

Now, you can finally run the server:

bun dev

Note: Whenever you change the schema, run these commands:

  1. bunx drizzle-kit generate: Generating SQL migration files from Drizzle ORM
  2. bunx drizzle-kit migrate: Push schema changes to database

Deploy

Fork this repo, and create a project in your vercel account by connecting the forked repo.