Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"rules": {
"type-enum": [
2,
"always",
[
"feat",
"fix",
"doc",
"perf",
"refactor",
"style",
"test",
"chore",
"security",
"revert"
]
]
}
}
18 changes: 15 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# App
APP_NAME="nodejs-template"
APP_PORT=3000
LOG_LEVEL="info"

# LOG
LOG_LEVEL=info # trace is the lowest, fatal the highest
LOG_SAMPLING_RATE=0.05

# Database
DATABASE_PORT=5432
DATABASE_HOST=localhost
DATABASE_USER="postgres"
DATABASE_PASSWORD="postgres"
DATABASE_NAME="postgres"
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_MAX=10

# OTEL
OTEL_EXPORTER_OTLP_ENDPOINT="http://otel-collector:4318"

# OTHER
NPM_PACKAGE_VERSION="1.0.0"

# TODO: ratelimiting, json payload sizes, http logger
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ A Node.js template for building RESTful APIs. Includes:
- Docker
- PostgreSQL
- An example RESTful API
- Wide events based logging
- Otel tracing support
- Metrics support for Prometheus

The project structures follows the [Tao of Node](https://alexkondov.com/tao-of-node/), which I've found very useful during my career.

Logging follows the philosophy from [this](https://loggingsucks.com/) blog.

## Quickstart

You need to have
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dev": "NODE_ENV=development tsx watch src/index.ts",
"typecheck": "tsc",
"test": "vitest run && vitest run --config vitest.integration.config.ts",
"test:debug": "vitest run --printConsoleTrace=true --silent=false && vitest run --config vitest.integration.config.ts --printConsoleTrace=true --silent=false",
"test:watch": "vitest",
"test:unit": "vitest run",
"test:integration": "vitest run --config vitest.integration.config.ts",
Expand Down Expand Up @@ -51,14 +52,23 @@
"vitest": "^4.1.7"
},
"dependencies": {
"@opentelemetry/api": "^1.9.1",
"@opentelemetry/auto-instrumentations-node": "^0.76.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.218.0",
"@opentelemetry/resources": "^2.7.1",
"@opentelemetry/sdk-node": "^0.218.0",
"@opentelemetry/sdk-trace-node": "^2.7.1",
"@opentelemetry/semantic-conventions": "^1.41.1",
"cors": "^2.8.6",
"dotenv": "^17.4.2",
"express": "^5.2.1",
"express-rate-limit": "^8.5.2",
"helmet": "^8.1.0",
"http-status-codes": "^2.3.0",
"kysely": "^0.29.2",
"pg": "^8.21.0",
"pino": "^10.3.1",
"prom-client": "^15.1.3",
"zod": "^4.4.3"
}
}
Loading