Am I using C++ the wrong way by making it feel TypeScript-like?
I’ve liked C++ since around 2014. I love that it’s compiled, object-oriented, doesn’t have garbage collection, and has clean, well-structured syntax.
But even though I’ve liked it for a long time, I never managed to get a job using it. I was still a newbie, and nobody really hires beginners in C++. So for work I moved to Node.js and PHP. I also enjoy JavaScript because it still feels somewhat similar to C-style languages.
Now, I finally have the freedom to choose my own tech stack again. I want to return to C++, but I’m having a hard time finding a simple, beginner-friendly C++ web framework. The closest thing that works for me is Boost.Beast, but it still feels very low-level.
Because of that, I ended up building my own small wrapper and started writing C++ in a more “TypeScript-ish” style. Now I’m wondering if I’m doing something wrong. Should I not shape C++ like that?
I’d appreciate any opinions or advice from you all.
Screenshot of my TypeScript-style C++ code: [
https://imgur.com/a/MjxrzSJ](https://imgur.com/a/MjxrzSJ)
in case the imgur link down:
// ========================================
// AUTHENTICATION ROUTES
// ========================================
server->post(base_path + "/auth/register", auth_router.register_user);
server->post(base_path + "/auth/login", auth_router.login);
server->post(base_path + "/auth/logout", auth_router.logout);
server->get(base_path + "/auth/me", auth_router.get_current_user);
server->post(base_path + "/auth/refresh", auth_router.refresh_token);
server->post(base_path + "/auth/verify-email", auth_router.verify_email);
server->post(base_path + "/auth/forgot-password", auth_router.forgot_password);
server->post(base_path + "/auth/reset-password", auth_router.reset_password);
server->post(base_path + "/auth/change-password", auth_router.change_password);
// ========================================
// USER ROUTES
// ========================================
server->get(base_path + "/users", user_router.list);
server->post(base_path + "/users", user_router.create);
server->put(base_path + "/users/:id", user_router.update);
// ========================================
// STORE ROUTES
// ========================================
// Store management
server->get(base_path + "/stores", store_router.list);
server->get(base_path + "/stores/:id", store_router.get_by_id);
server->post(base_path + "/stores", store_router.create);
server->put(base_path + "/stores/:id", store_router.update);
server->del(base_path + "/stores/:id", store_router.remove);
server->put(base_path + "/stores/:id/owner", store_router.transfer_ownership);
// Store managers
server->get(base_path + "/stores/:id/managers", store_router.list_managers);
server->post(base_path + "/stores/:id/managers", store_router.add_manager);
server->del(base_path + "/stores/:id/managers/:userId", store_router.remove_manager);
// Store locations
server->get(base_path + "/stores/:id/locations", store_router.list_locations);
server->post(base_path + "/stores/:id/locations", store_router.add_location);
server->put(base_path + "/stores/:id/locations/:locationId", store_router.update_location);
server->del(base_path + "/stores/:id/locations/:locationId", store_router.delete_location);
// Working hours
server->get(base_path + "/stores/:id/working-hours", store_router.get_working_hours);
server->put(base_path + "/stores/:id/working-hours", store_router.update_working_hours);
// Store seats
server->get(base_path + "/stores/:id/seats", store_router.list_seats);