Prerequisites
Before you begin, ensure you have the required runtime environments installed:Node.js ≥ 22
Production deployment target
Bun ≥ 1.1
Local development (recommended)
Bun is recommended for local development as it provides native TypeScript support with no compilation step. However, the deployment target is Node.js 22.
Additional Requirements
- TypeScript ≥ 5.4 (strict mode required)
- ntn CLI for deployment (makenotion/workers-template)
- Package manager: npm (lockfile committed) or bun
Installation
Configure credentials
Set up your environment variables. See the Credentials Guide for detailed options.
Project Structure
The repository follows a clean architecture pattern:Module System
This project uses ESM (ECMAScript Modules):"type": "module"is set in package.json- Use
.jsextensions in import paths when importing from.tsfiles (NodeNext resolution)
Development Commands
Running Locally
Type Checking
Run TypeScript compiler checks without emitting files:This must pass before deployment. The project uses
strict: true with no exceptions.Build
Compile TypeScript for deployment:Code Standards
Naming Conventions
| Type | Convention | Example |
|---|---|---|
| Files | kebab-case | write-agent-digest.ts |
| Functions/variables | camelCase | getNotionClient |
| Types/interfaces | PascalCase | AgentDigestInput |
| Constants | SCREAMING_SNAKE_CASE | DOCS_DATABASE_ID |
| Notion IDs | 32-char hex, no dashes | abc123... |
Type Safety Rules
Strict Mode
strict: true — no exceptionsNo any
Use
unknown then narrowNo Assertions
No non-null assertions (
!) on API responsesExplicit Returns
All async functions should have explicit return types
Architecture Pattern
Pure logic separation:- Business logic (parsing, building, validating) →
src/shared/→ unit tested - Orchestration (validate input, call logic, call Notion, return result) →
src/workers/
Runtime Environment
Local Development
Local Development
- Uses Bun runtime
- Native TypeScript execution
- No compilation step needed
- Fast test execution with built-in test runner
Production Deployment
Production Deployment
- Uses Node.js 22 runtime
- Managed by Notion Workers platform
- Deployed via
ntnCLI - Pre-authenticated Notion client provided
Next Steps
Configure Credentials
Set up your environment variables and secrets
Run Tests
Learn about the testing strategy and run the test suite
Deploy Workers
Deploy your workers to production
Worker Architecture
Understand the worker system design