This is a simple chat app that uses websockets, and a postgreSQL database. The purpose of this project is to allow me to independantly learn how to use websockets and postgres.
Want to see a live demo? Head on over to chat.nawab-as.software
- Install this repository through git by
git clone https://github.com/Nawab-AS/chat_app.git
cd ./chat_app
- install node modules by
npm i
-
Create a postgreSQL database. there are multiple ways of doing this, one way to do this is by using the
createdbcommand in your terminal,This is not the only way to setup a PostgreSQL database, hense, you are not limited to only this method and can do it is any way you please
createdb <database_name>
Replace
<database_name>with the desired name for your database. You may need to adjust user permissions or connection settings depending on your PostgreSQL setup. -
Run
setup.sqlon the database through pgadmin, dbeaver, psql, etc to setup tables, functions and procedures -
Create a
.envfile in the root directory that constains the following.
Caution
The actual valus of the .env file should never be shared with anyone otherwise it could lead to a security breach
SESSION_KEY="<insert your session secret>"
DATABASE_URI="postgres://<username>:<password>@<host>:<port>/<database name>"
SESSION_KEYis a random cryptographically generated string that is used to authorize login sessions and encrypt user passwords, Because of this, it is essential that it remains the same and isn't leaked.DATABASE_URIcontains the necessary credentials to access your database.
Optionaly, you can use cloudflare turnstiles (similar to captcha).
Simply create a site and secret here and add the following to your .env file
CAPTCHA_SITE_KEY="<insert your site key>"
CAPTCHA_SECRET_KEY="<insert your secret key>"
Now captcha will be require during login and sign up.
- Run the server using the following command in terminal
npm run start
optionally you can also use the heroku cli as well with
heroku local
These are some sample screenshots
For any questions or concerns please email me at nawab-as@hackclub.app



