Glimpse
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v422View latest version
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.)
In this application, we have different directories for /controllers and /utils:
Aspect | Controller | Util |
---|---|---|
Purpose | Orchestrates business logic and workflows | Provides small, stateless helper functions |
Scope | High-level, often involves services or side effects | Low-level, narrow in focus (e.g., string, date ops) |
State | Works with application or user-specific data | Stateless – input in, output out |
Output | Often returns domain-specific result objects | Returns generic, context-agnostic values |
Example Names | syncDataToNotion , generateUserReport | formatDate , slugify , chunkArray , debounce |
Depends On | Services, repositories, other controllers | Pure logic, no external dependencies (ideally) |