This is a simple code snippet sharing web application, similar to pastebin, made with Drogon C++ Framework. It's completely anonymous, though I'm planning on bringing here some convenient authentication.
- Prerequisites
- Cloning the Repository
- Building the Project
- Database Setup
- Configuration
- Running the Application
Before you begin, ensure you have the following installed:
- C++ Compiler: A C++20 compatible compiler.
- CMake: Version 3.10 or higher.
- PostgreSQL: A running PostgreSQL server.
- Drogon: The Drogon C++ web framework. Shipped as a submodule.
- jwt-cpp: The JWT (JSON Web Tokens) library for C++. Shipped as a submodule.
- libpq-dev: The PostgreSQL client library development headers.
- uuid-dev: The UUID library development headers.
-
Open your terminal and navigate to the directory where you want to clone the project.
-
Run the following command:
git clone --recursive --depth=1 --shallow-submodules https://github.com/1Kuso4ek1/PBin-cpp.git cd PBin-cppNote: The
--depth=1 --shallow-submodulesflags are used for faster cloning. If you need to work with the Drogon submodule directly (e.g., switch branches), you might need to clone without these flags.
-
Create a build directory:
mkdir build cd build -
Configure the project using CMake:
cmake .. -DCMAKE_BUILD_TYPE=Release
-
Build the project:
make -j$(nproc)
-
Create a Database:
- Connect to your PostgreSQL server using
psqlor a GUI tool like pgAdmin. - Create a new user and database.
- For example:
CREATE USER your_db_user WITH PASSWORD 'your_db_password'; CREATE DATABASE pbin WITH OWNER your_db_user; GRANT ALL PRIVILEGES ON DATABASE pbin TO your_db_user;
- Replace
your_db_user,your_db_password, andpbinwith your desired username, password, and database name.
- Replace
- Connect to your PostgreSQL server using
-
Create tables:
- You need to create tables in a database.
- In the
sqlfolder you can findcreate_tables.sqlfile, which contains all the necessary queries. - Connect to your database using
psqlor pgAdmin:psql -U your_db_user -d pbin
- Run the
create_tables.sqlfile:\i /path/to/this/project/sql/create_tables.sql
- Replace
/path/to/this/project/sql/create_tables.sqlwith the actual path to the file.
- Replace
There's a config/config-template.json file, which you should use as a template for your configuration. You can either make changes to this file directly, or copy/rename/move it. Either way, you need to fill in your database credentials, server port, and other settings.
-
Navigate to the
builddirectory:cd build -
Run the executable:
./backend
This will start the Drogon web server.
-
If you moved the default
config/config-template.jsonfile, you can provide a path to your config file as an argument:./backend /path/to/your/config.json