README
Douze
A Twelve Factor app framework for Node.js written in TypeScript.
Features
- 🏗️ App scaffolding with Express
- 🌲 Logging with Pino
- 🚨 Error reporting with Sentry
- 📦 Extensible with plugins (batteries included, but opt-in)
- 🌍 Configuration via environment variables
- 🛠️ Admin processes through Tasks
Plugins
douze-sequelize
: Use Sequelize as an ORM for SQL databasesdouze-mongo
: MongoDB ODM (coming soon)douze-redis
: Redis cache & KV store (coming soon)douze-graphql
: GraphQL with Apollo Server 2.0 (coming soon)
Installation
$ yarn add douze
# or
$ npm install douze
Usage
// index.ts
import Douze, { Request, Response } from 'douze'
const douze = new Douze()
// Create an application with default configuration
const app = douze.createApp()
// Attach standard Express routes & middleware to your app:
app.use('/', (req: Request, res: Response) => {
res.json({ hello: 'world' })
})
await douze.start(app)
This basic example shows sensible default configuration, overridable by environment variables where relevant.
Environment
Douze is configured by environment variables where relevant, rather than code.
Here is a list of configuration environment variables:
Name | Type | Default | Description |
---|---|---|---|
APP_NAME |
string | 'douze-app' |
The name of your application |
NODE_ENV |
string | 'development' |
|
LOG_LEVEL |
string | 'debug' in development, 'info' in production. |
Any of the levels defined in Pino |
HOST |
string | '0.0.0.0' |
Listening address |
PORT |
number | 3000 |
Listening port |
SENTRY_DSN |
string | undefined | Enable Sentry error reporting by passing it the DSN to use |
DOUZE_FINGERPRINT_SALT |
string | random | A salt applied to the anonimisation function, rotate it to anonymise against previous logs |
DOUZE_DATABASE_FORCE_SYNC |
boolean | undefined | Set to true in development to reset the database and sync the models. Existing data will be lost ! |
DOUZE_DATABASE_SEED |
boolean | undefined | Run seeding functions in development to start with fresh data. |
DOUZE_ENFORCE_PRIVACY |
boolean | true | Redact privacy-busting information from logs in production (headers, source IP) |
Deployment variables (used to track deployed instances, those are set by default on Clever Cloud):
POSTGRESQL_ADDON_URI
: URI to the PostgreSQL databaseCOMMIT_ID
: Git commit ID of the deploymentINSTANCE_ID
INSTANCE_NUMBER