Experimenting with REST API using CrowCpp and SqliteModernCpp with Mustache for SSR HTML.
This project is a web application built using CrowCpp for handling HTTP requests and responses. The project uses a combination of CrowCpp for server-side routing, SQLite for database management, and Mustache for rendering HTML templates.
- User authentication and password management
- RESTful API design
- SQLite database integration
- Mustache templating for dynamic HTML rendering
- Email notifications using
curl
for password reset functionality
/reset_password/<string>/<string>
- GET request for displaying the password reset page with email and token validation./reset_password/<string>/<string>/<string>
- POST request for handling password reset with a new password./forgot_password/<string>
- POST request for sending a password reset email./like
- POST request for liking or unliking a post./like_reply/<int>
- POST request for liking or unliking a reply./load_my_posts
- GET request to load the current user's posts./load_users_posts/<int>
- GET request to load posts by a specific user./home
- GET request to load the homepage with recent posts./submit_post
- POST request for submitting a new post./edit_post/<int>
- POST request for editing a specific post./delete_post/<int>
- DELETE request for deleting a specific post./reply/<int>
- POST request for replying to a specific post./load_replies/<int>
- GET request to load replies for a specific post./edit_reply/<int>
- PUT request for editing a specific reply./delete_reply/<int>
- DELETE request for deleting a specific reply./user_data/<int>/prof_pic/<string>
- GET request to display a user's profile picture./user_data/<int>/post_pic/<string>
- GET request to display a user's post picture./register
- POST request to register a new user./verify/<string>/<string>
- GET request for verifying the user's email./login
- POST request for logging in a user./profile
- GET request to display the logged-in user's profile./prof/<int>
- GET request to display another user's profile./edit_user
- POST request to edit the logged-in user's profile./delete_user
- DELETE request to delete the logged-in user's account./logout
- GET request to log out the current user./
- GET request to load the homepage or login page, depending on the user's session.
- C++ - Core language used for developing the application
- CrowCpp - Lightweight HTTP server framework
- SQLite - Database for storing user data and tokens
- Mustache - HTML templating engine for rendering views
- curl - Command-line tool for sending emails for password recovery
To build the project, make sure you have CMake
installed. Follow these steps:
git clone https://github.com/Ioannis-Markos-Angelidakis/crowcpp_rest_api.git
cd crowcpp_rest_api
mkdir build
cd build
cmake ..
make
./account
This project uses FetchContent
to download dependencies (CrowCpp and SqliteModernCpp) as part of the CMake configuration. Below is the relevant CMake file:
cmake_minimum_required(VERSION 3.20)
project(MyCrowProject LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# FetchContent module to download dependencies
include(FetchContent)
# CrowCpp
FetchContent_Declare(
CrowCpp
GIT_REPOSITORY https://github.com/CrowCpp/Crow.git
GIT_TAG master
)
FetchContent_MakeAvailable(CrowCpp)
# SqliteModernCpp
FetchContent_Declare(
SqliteModernCpp
GIT_REPOSITORY https://github.com/SqliteModernCpp/sqlite_modern_cpp.git
GIT_TAG master
)
FetchContent_MakeAvailable(SqliteModernCpp)
add_executable(${PROJECT_NAME} account.cpp)
# Link CrowCpp and SqliteModernCpp
target_link_libraries(${PROJECT_NAME}
PRIVATE
Crow::Crow
sqlite_modern_cpp
)
# Include directories for SqliteModernCpp (if needed)
target_include_directories(${PROJECT_NAME} PRIVATE ${SqliteModernCpp_SOURCE_DIR})
After running CMake, the necessary dependencies will be automatically downloaded and linked to the project.
Once the server is running, you can access the web application through localhost:8080
and interact with the various routes.