This is a blogging platform where users can create blogs, follow other users, and manage their profiles.
POST /api/register
{
"username": "newuser",
"email": "newuser@gmail.com",
"password": "password123"
}
{
"message": "User registered successfully"
}
POST /api/login
{
"email": "newuser@gmail.com",
"password": "password123"
}
{
"token": "Session Token"
}
GET /api/blogs
[
{
"id": 1,
"owner_id": 1,
"title": "My First Blog",
"media": "media1.jpg",
"content": "This is my first blog",
"updated_at": "2024-09-12T12:00:00Z"
}
]
POST /api/blogs
{
"owner_id": 1,
"title": "New Blog",
"media": "image.jpg",
"content": "Content of the blog."
}
{
"message": "Blog created successfully."
}
{
"user_id": 1,
"followed_id": 2
}
{
"message": "User followed successfully."
}
{
"user_id": 1,
"token": "Session Token"
}
{
"message": "Session created."
}
Column Name | Data Type | Description |
---|---|---|
id | INT | Primary key, auto-increment |
username | VARCHAR(255) | User's username |
password | VARCHAR(255) | User's password (hashed) |
VARCHAR(255) | User's email (unique) | |
avatar | VARCHAR(255) | Path to avatar image |
bio | TEXT | User bio |
Column Name | Data Type | Description |
---|---|---|
id | INT | Primary key, auto-increment |
user_id | INT | Foreign key to users.id |
token | VARCHAR(255) | Unique session token |
Column Name | Data Type | Description |
---|---|---|
id | INT | Primary key, auto-increment |
owner_id | INT | Foreign key to users.id |
title | VARCHAR(255) | Title of the blog |
media | VARCHAR(255) | Media associated with blog |
content | TEXT | Blog content |
updated_at | TIMESTAMP | Last updated time |
Column Name | Data Type | Description |
---|---|---|
id | INT | Primary key, auto-increment |
user_id | INT | Foreign key to users.id |
followed_id | INT | Foreign key to users.id |
To get the project up and running locally, follow these steps:
Clone the repository:
git clone https://github.com/a-box31/ABlog.git
Navigate to the backend directory:
cd backend
Install the required dependencies:
npm install
Set up the MySQL database:
ABlogDB.session.sql
) to set up the database tables.Example of setting up the tables:
CREATE DATABASE blogApp;
USE blogApp;
-- Create users table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
avatar VARCHAR(255) DEFAULT 'default.png',
bio TEXT
);
-- Create other tables as needed...
Set up environment variables:
.env
file in the backend root directory.
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=blogApp
COOKIE_EXPIRY=86400000 PORT=3000 CLIENT_URL='http://client_domain_name' SERVER_DOMAIN='http://server_domain_name'
Run the backend server:
npm run dev
The backend server will be running on http://localhost:3000
.
Navigate to the frontend directory:
cd frontend
Install the required dependencies:
npm install
Start the frontend server:
npm run dev
The frontend server will be running on http://localhost:5173
.
Now, the app should be fully functional with both the backend and frontend running locally.