This is a simple backend implementation for a real-time chatting web app using Node.js, Socket.io, and Prisma hooked to a PostgreSQL database. You can see a pairing frontend implementation in one of my other repositories.
-
Clone this repository
-
Make sure you have npm and Node.js version 14 or higher installed
-
Install the required packages,
npm install
-
Create a
.envfile in the root directory and define the following environment variables,PORT: the desired port for the serverFRONT_END_DEPLOYMENT: the URL of your frontend appDATABASE_URL: the URL of your PostgreSQL database
Below is an example,
PORT=8080 FRONT_END_DEPLOYMENT="http://localhost:3000" DATABASE_URL="postgresql://user:password@host:port/database?schema=public"
-
Run the following to migrate the Prisma schema into your database and generate a Prisma client,
npx prisma db push npx prisma generate
-
Start the server,
npm start