Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion timetable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ cmake_minimum_required(VERSION 3.26)
project(timetable)

set(CMAKE_CXX_STANDARD 17)

include_directories(/opt/homebrew/include)
include_directories(/opt/homebrew/include/mongocxx/v_noabi)
include_directories(/opt/homebrew/include/bsoncxx/v_noabi)
include_directories(/opt/homebrew/include/bsoncxx/v_noabi/bsoncxx)
add_executable(
timetable cmd/timetable/application.cpp
cmd/timetable/controllers/system_controller.h
cmd/timetable/controllers/timetable_controller.h

)
45 changes: 35 additions & 10 deletions timetable/cmd/timetable/application.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
#include "libs/json.hpp"
#include "libs/cpp-httplib/httplib.h"
#include "controllers/system_controller.h"
#include "controllers/timetable_controller.h"

int main() {
Server svr;
svr.Get("/timetable/system/test", handler);
svr.Get("/timetable/getTimetableForGroup", get_timetable_for_group);
svr.listen("0.0.0.0", 8080);
//#include <nlohmann/json.hpp>
//#include <httplib.h>
//#include "controllers/system_controller.h"
//#include "controllers/timetable_controller.h"
//
//int main() {
// Server svr;
// svr.Get("/timetable/system/test", handler);
// svr.Get("/timetable/getTimetableForGroup", get_timetable_for_group);
// svr.listen("0.0.0.0", 8080);
//}

#include <iostream>

#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>

#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>

int main(int, char**) {
mongocxx::instance inst{};
mongocxx::client conn{mongocxx::uri{}};

bsoncxx::builder::stream::document document{};

auto collection = conn["testdb"]["testcollection"];
document << "hello" << "world";

collection.insert_one(document.view());
auto cursor = collection.find({});

for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
}
}
4 changes: 2 additions & 2 deletions timetable/cmd/timetable/controllers/system_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef TIMETABLE_SYSTEM_CONTROLLER_H
#define TIMETABLE_SYSTEM_CONTROLLER_H

#include "../libs/json.hpp"
#include "../libs/cpp-httplib/httplib.h"
#include "nlohmann/json.hpp"
#include <httplib.h>

using json = nlohmann::json;

Expand Down
4 changes: 2 additions & 2 deletions timetable/cmd/timetable/controllers/timetable_controller.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../libs/cpp-httplib/httplib.h"
#include "../libs/json.hpp"
#include <httplib.h>
#include "nlohmann//json.hpp"

using json = nlohmann::json;

Expand Down
1 change: 0 additions & 1 deletion timetable/cmd/timetable/libs/cpp-httplib
Submodule cpp-httplib deleted from b85690
Loading