- Clone the repository.
git clone https://www.github.com/ARandomDev99/dash.git
cd dash
- Install dependencies.
npm install
- Create a
.env
file in the root directory and give appropriate values to the following:
PGUSER
: PostgreSQL userPGPASSWORD
: Password forPGUSER
PORT
: The port which the server should listen to (default: 3000)JWT_SECRET
: Secret key for JSON Web Token
Optionally, additional .env
variables related to the database can be added.
Refer to the documentation for node-postgres
.
Ensure that PGUSER
has the necessary permissions to manage the database and its tables. 4. Start the PostgreSQL server. 4. Start the development server.
npm run dev
This command will build the SvelteKit app and start the Express server.
The server will listen to the port specified in the .env
file.
The project uses SvelteKit + Tailwind CSS for frontend and Express to provide API endpoints.
SvelteKit uses adapter-node
for integration with Express.
index.js
calls a function that initializes the PostgreSQL tables if they don't already exist:
CREATE SCHEMA IF NOT EXISTS dash;
CREATE TABLE IF NOT EXISTS dash.users (
username TEXT PRIMARY KEY,
password TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS dash.channels (
id BIGSERIAL PRIMARY KEY,
user1 TEXT NOT NULL REFERENCES dash.users(username),
user2 TEXT NOT NULL REFERENCES dash.users(username)
);
CREATE TABLE IF NOT EXISTS dash.messages (
id BIGSERIAL PRIMARY KEY,
channel BIGINT NOT NULL REFERENCES dash.channels(id),
author TEXT NOT NULL REFERENCES dash.users(username),
content TEXT NOT NULL
);