The files in this directory export functions that get data from and save data to Notion. Most of these functions are used by /tasks.

Every controller in this directory includes the Notion client:

import { Client } from "npm:@notionhq/client";

// Initialize Notion client
const notion = new Client({
  auth: Deno.env.get("NOTION_API_KEY"),
});

Keeping controllers in this directory and importing them into our routes keeps our API endpoints thin and easier to work with. (See the /tasks directory as an example.)

Re: /controllers and /utils

In this application, we have different directories for /controllers and /utils:

AspectControllerUtil
PurposeOrchestrates business logic and workflowsProvides small, stateless helper functions
ScopeHigh-level, often involves services or side effectsLow-level, narrow in focus (e.g., string, date ops)
StateWorks with application or user-specific dataStateless – input in, output out
OutputOften returns domain-specific result objectsReturns generic, context-agnostic values
Example NamessyncDataToNotion, generateUserReportformatDate, slugify, chunkArray, debounce
Depends OnServices, repositories, other controllersPure logic, no external dependencies (ideally)