To run the server, you need to build the project first. See the Building section for more information.
After building the project, you can run the server by running the executable in root directory of the project.
./build/shortenerExecutable expects ./static directory to be present in current working directory.
This endpoint is used to shorten a URL. It expects a JSON payload with a key url containing the URL to shorten.
In request body:
{
"url": "https://example.com/really/long/url"
}On success:
201 Created
application/json with body:
{
"id": "random_id"
}On error:
400 Bad Request - invalid json body (no url key, malformed json, etc.).
500 Internal Server Error - database related error.
text/plain - Body contains error message.
This endpoint is used to redirect to the original URL. It expects a path parameter id containing the shortened URL ID.
id - shortened URL ID. Can be obtained from POST /short response.
on success:
302 Found with header Location: <original_url>
on error:
404 Not Found - shortened URL ID not found.
400 Bad Request - invalid shortened URL ID (couldn't be parsed).
This endpoint is used to delete a shortened URL. It expects a path parameter id containing the shortened URL ID.
id - shortened URL ID. Can be obtained from POST /short response.
on success:
204 No Content
on error:
400 Bad Request - invalid shortened URL ID (couldn't be parsed).
500 Internal Server Error - database related error.
This endpoint serves the static files from ./static directory. It is used to serve the frontend.
I've tried to make this project, and its core - the comet framework, as portable as possible. It should work on any platform that supports CMake and C99, but I've only tested it on Linux in Mint variety.
This project depends on sqlite3 dev library. It is not shipped with the project, nor is it included as a submodule. You need to have it installed on your system. On debian-likes, you can install it by running:
sudo apt install libsqlite3-devIntended building process uses cmake:
In root directory of the project run:
cmake -S . -B build && cmake --build buildIf cmake complains about missing some files / libraries, run:
git submodule update --init --recursive