This is an example blog app built with Ecewo and PostgreSQL.
Warning
This is not a real-world app. It is built to show what Ecewo looks like.
Using dependencies:
- ecewo-postgres for integration of async PostgreSQL queries with Ecewo, based on libuv and libpq
- ecewo-cookie for cookie management
- ecewo-session for session-based authentication
- ecewo-cors for CORS implementation
- ecewo-helmet for security headers
- cJSON for handling JSON objects
- slugify-c for creating URL-friendly ASCII characters
- dotenv-c for managing environment variables
- libsodium for password hashing with
argon2
- CMake version 3.14 or higher
- libpq
- libsodium (Not required on Windows, as it's already included in the
vendors/libsodium-win64folder)
git clone https://github.com/savashn/ecewo-example.git
cd ecewo-exampleBefore compiling the program, create a .env file in the project's root directory and define the following environment variables. Otherwise, you may encounter a segmentation fault at startup.
PORT
DB_HOST
DB_PORT
DB_NAME
DB_USER
DB_PASSWORD
You can build with the following command:
./build.shIf you make some changes on the project and would lite to build from scratch:
./build.sh rebuildIf you prefer to build manually, run the suitable command:
Manually building on Windows:
mkdir build && cd build && cmake .. && cmake --build . && ./server.exeManually building on Linux/macOS:
mkdir build && cd build && cmake .. && cmake --build . && ./serverYou can see all the endpoints in src/routers/routers.c file.
Here are what POST and PUT endpoints wait for:
POST /register
{
"name": "John Doe",
"username": "johndoe",
"password": "123123",
"email": "noone@nowhere.com",
"about": "About John Doe"
}POST /login
{
"username": "johndoe",
"password": "123123"
}OR
{
"email": "noone@nowhere.com",
"password": "123123"
}POST /create/category
{
"category": "John Doe's Test Category"
}POST /create/post
{
"header": "John Doe's Example Post",
"content": "John Doe's example post content",
"categories": [1]
}PUT /user/:user/categories/:category
{
"category": "John Doe's Edited Test Category"
}PUT /user/:user/posts/:post
{
"header": "John Doe's Edited Example Post",
"content": "John Doe's edited example post content",
"categories": []
}