Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
use axum::Router;
use axum::routing::post;
use crate::api::ApiContext;
pub(crate) mod attachments;
pub(crate) mod backfill;
pub(crate) mod contacts;
pub(crate) mod drafts;
pub(crate) mod filters;
pub(crate) mod init;
pub(crate) mod labels;
pub(crate) mod links;
pub(crate) mod messages;
pub(crate) mod provider_error;
pub(crate) mod settings;
pub(crate) mod sync;
pub(crate) mod threads;
pub fn router(state: ApiContext) -> Router<ApiContext> {
Router::new()
.nest("/attachments", attachments::router(state.clone()))
.nest("/labels", labels::router(state.clone()))
.nest("/threads", threads::router(state.clone()))
.route(
"/draft-transfers/{id}/recover",
axum::routing::post(drafts::transfer::recover),
)
.nest("/drafts", drafts::router(state.clone()))
.nest("/messages", messages::router(state.clone()))
.nest("/links", links::router())
.nest("/contacts", contacts::router(state.clone()))
.nest("/filters", filters::router())
.nest("/backfill", backfill::router(state.clone()))
.nest("/settings", settings::router(state.clone()))
.nest("/sync", sync::router(state.clone()))
// deleting all user info from the db can take a long time - prevent connection from dropping
.layer(axum::middleware::from_fn(
macro_middleware::connection_drop_prevention_handler,
))
.route("/init", post(init::handler))
}