- Express
- MySql
- Knex
- Uuid
- Bcrypt
- JsonWebToken
- Dotenv
- Cors
-
Clone this repository into your machine
-
Open your preferred CLI inside the cloned repo and run the following commands:
npm install
touch .env
start .env
-
Paste the following environment variables into your .env file, replacing their values for those of your own SQL database:
DB_USER = me DB_PASSWORD = xxxxxxxxxxxxxxxxxxxx DB_NAME = myschema JWT_KEY = xxxxxxxxxxxx
-
Run the following queries on your SQL database:
CREATE TABLE future_book_users ( id VARCHAR(255) PRIMARY KEY, name VARCHAR(255) UNIQUE NOT NULL, email VARCHAR(255) UNIQUE NOT NULL, password VARCHAR(255) UNIQUE );
CREATE TABLE future_book_friends ( user_id VARCHAR(255), friend_id VARCHAR(255), PRIMARY KEY (user_id , friend_id), FOREIGN KEY (user_id) REFERENCES future_book_users (id), FOREIGN KEY (friend_id) REFERENCES future_book_users (id) );
CREATE TABLE future_book_posts ( id VARCHAR(255) PRIMARY KEY, author_id VARCHAR(255), description VARCHAR(255), creation_date DATETIME, type VARCHAR(255), img VARCHAR(255), FOREIGN KEY (author_id) REFERENCES future_book_users (id) );
CREATE TABLE future_book_likes ( friend_id VARCHAR(255), post_id VARCHAR(255), PRIMARY KEY (friend_id , post_id), FOREIGN KEY (friend_id) REFERENCES future_book_users (id), FOREIGN KEY (post_id) REFERENCES future_book_posts (id) );
CREATE TABLE future_book_comments ( id VARCHAR(255) PRIMARY KEY, friend_id VARCHAR(255), post_id VARCHAR(255), comment_text VARCHAR(255), FOREIGN KEY (friend_id) REFERENCES future_book_users (id), FOREIGN KEY (post_id) REFERENCES future_book_posts (id) );
-
Run
npm run start
on your CLI -
Open your browser's localhost and test the endpoints using this project's own GUI. You'll find templates for all available requests, but feel free to send them via other softwares such as Postman.