Skip to content

Commit 794b5b2

Browse files
authored
Merge pull request #3 from typelets/feat/valkey-caching
feat: add Valkey caching layer with New Relic monitoring and structur…
2 parents fcfd58b + ee93a6d commit 794b5b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1834
-1566
lines changed

.env.example

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ DATABASE_URL=postgresql://postgres:devpassword@localhost:5432/typelets_local
1717
# For production (example):
1818
# DATABASE_URL=postgresql://username:password@hostname:5432/database?sslmode=require
1919

20-
# Database Connection Pooling (OPTIONAL)
21-
# DB_POOL_MAX=20 # Maximum connections in pool (default: 20)
22-
# DB_IDLE_TIMEOUT=20 # Close idle connections after N seconds (default: 20)
23-
# DB_CONNECT_TIMEOUT=10 # Connection timeout in seconds (default: 10)
20+
# Valkey Cache (OPTIONAL - for performance optimization)
21+
# VALKEY_HOST=your-cluster.serverless.use1.cache.amazonaws.com
22+
# VALKEY_PORT=6379
2423

2524
# Clerk Authentication (REQUIRED)
2625
# Get your secret key from: https://dashboard.clerk.com/
@@ -31,6 +30,7 @@ CLERK_SECRET_KEY=sk_test_your_actual_clerk_secret_key_from_dashboard
3130
# CORS Origins (REQUIRED)
3231
# Comma-separated list of allowed origins (no spaces after commas)
3332
# Include all frontend domains that will access this API
33+
# If not set, all cross-origin requests will be blocked
3434
CORS_ORIGINS=http://localhost:5173,http://localhost:3000
3535
# Production example:
3636
# CORS_ORIGINS=https://app.typelets.com,https://typelets.com
@@ -66,10 +66,10 @@ MESSAGE_AUTH_SECRET=your-very-secure-random-string-here-min-32-chars
6666
# HTTP_FILE_RATE_LIMIT_MAX=100 # Max file operations per window
6767

6868
# WebSocket Rate Limiting
69-
WS_RATE_LIMIT_WINDOW_MS=60000 # Time window: 1 minute (in milliseconds)
70-
WS_RATE_LIMIT_MAX_MESSAGES=300 # Max messages per window per connection
71-
WS_MAX_CONNECTIONS_PER_USER=20 # Max concurrent connections per user
72-
WS_AUTH_TIMEOUT_MS=30000 # Authentication timeout: 30 seconds
69+
WS_RATE_LIMIT_WINDOW_MS=60000# Time window: 1 minute (in milliseconds)
70+
WS_RATE_LIMIT_MAX_MESSAGES=300# Max messages per window per connection
71+
WS_MAX_CONNECTIONS_PER_USER=20# Max concurrent connections per user
72+
WS_AUTH_TIMEOUT_MS=30000# Authentication timeout: 30 seconds
7373

7474
# Production Rate Limiting Recommendations:
7575
# - HTTP: 500-1000 requests per 15 minutes per user
@@ -82,7 +82,7 @@ WS_AUTH_TIMEOUT_MS=30000 # Authentication timeout: 30 seconds
8282
# ================================================================
8383

8484
# File Size Limits
85-
MAX_FILE_SIZE_MB=50 # Maximum size per file (default: 50MB)
85+
MAX_FILE_SIZE_MB=50# Maximum size per file (default: 50MB)
8686
# MAX_NOTE_SIZE_MB=1024 # Maximum total attachments per note (default: 1GB)
8787

8888
# Allowed File Types (handled in code, documented here)
@@ -107,8 +107,8 @@ MAX_FILE_SIZE_MB=50 # Maximum size per file (default: 50MB)
107107
# ================================================================
108108

109109
# Free Tier Limits
110-
FREE_TIER_STORAGE_GB=1 # Storage limit for free users (default: 1GB)
111-
FREE_TIER_NOTE_LIMIT=100 # Note count limit for free users (default: 100)
110+
FREE_TIER_STORAGE_GB=1# Storage limit for free users (default: 1GB)
111+
FREE_TIER_NOTE_LIMIT=100# Note count limit for free users (default: 100)
112112

113113
# Usage tracking for billing analytics
114114
# These limits trigger billing events logged to console
@@ -118,6 +118,12 @@ FREE_TIER_NOTE_LIMIT=100 # Note count limit for free users (default
118118
# LOGGING & MONITORING
119119
# ================================================================
120120

121+
# New Relic APM (OPTIONAL - for production monitoring)
122+
# Get your license key from: https://one.newrelic.com
123+
# NEW_RELIC_APP_NAME=Typelets API
124+
# NEW_RELIC_LICENSE_KEY=your_license_key_here
125+
# NEW_RELIC_LOG_LEVEL=warn # Options: error, warn, info, debug, trace (default: warn in dev, info in prod)
126+
121127
# Debug Logging
122128
# DEBUG=false # Set to true for verbose logging (not recommended in production)
123129

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12-
12+
1313
strategy:
1414
matrix:
1515
node-version: [20.x, 22.x]
16-
16+
1717
steps:
1818
- uses: actions/checkout@v4
19-
19+
2020
- name: Use Node.js ${{ matrix.node-version }}
2121
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
24-
24+
2525
- name: Setup pnpm
2626
uses: pnpm/action-setup@v4
2727
with:
2828
version: 9.15.0
29-
29+
3030
- name: Install dependencies
3131
run: pnpm install
32-
32+
3333
- name: Run linting
3434
run: pnpm run lint
35-
35+
3636
- name: Run build
37-
run: NODE_OPTIONS="--max-old-space-size=8192" pnpm run build
37+
run: NODE_OPTIONS="--max-old-space-size=8192" pnpm run build

.github/workflows/codeql.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77
branches: [main]
88
schedule:
9-
- cron: '0 0 * * 0'
9+
- cron: "0 0 * * 0"
1010

1111
jobs:
1212
analyze:
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
language: ['typescript']
23+
language: ["typescript"]
2424

2525
steps:
2626
- name: Checkout repository
@@ -34,8 +34,8 @@ jobs:
3434
- name: Setup Node.js
3535
uses: actions/setup-node@v4
3636
with:
37-
node-version: '20'
38-
37+
node-version: "20"
38+
3939
- name: Setup pnpm
4040
uses: pnpm/action-setup@v4
4141
with:
@@ -48,4 +48,4 @@ jobs:
4848
run: NODE_OPTIONS="--max-old-space-size=8192" pnpm run build
4949

5050
- name: Perform CodeQL Analysis
51-
uses: github/codeql-action/analyze@v3
51+
uses: github/codeql-action/analyze@v3
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Change Tracking Marker
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
newrelic:
8+
runs-on: ubuntu-latest
9+
name: New Relic
10+
steps:
11+
# This step builds a var with the release tag value to use later
12+
- name: Set Release Version from Tag
13+
run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
14+
# This step creates a new Change Tracking Marker
15+
- name: New Relic Application Deployment Marker
16+
uses: newrelic/deployment-marker-action@v2.3.0
17+
with:
18+
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
19+
guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID }}
20+
version: "${{ env.RELEASE_VERSION }}"
21+
user: "${{ github.actor }}"

.github/workflows/release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,34 @@ on:
77
jobs:
88
release:
99
runs-on: ubuntu-latest
10-
10+
1111
permissions:
1212
contents: write
1313
issues: write
1414
pull-requests: write
15-
15+
1616
steps:
1717
- uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
20-
20+
2121
- name: Setup Node.js
2222
uses: actions/setup-node@v4
2323
with:
24-
node-version: '20'
25-
24+
node-version: "20"
25+
2626
- name: Setup pnpm
2727
uses: pnpm/action-setup@v4
2828
with:
2929
version: 9.15.0
30-
30+
3131
- name: Install dependencies
3232
run: pnpm install
33-
33+
3434
- name: Build
3535
run: NODE_OPTIONS="--max-old-space-size=8192" pnpm run build
36-
36+
3737
- name: Release
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
run: npx semantic-release
40+
run: npx semantic-release

.prettierignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Dependencies
2+
node_modules/
3+
pnpm-lock.yaml
4+
package-lock.json
5+
yarn.lock
6+
7+
# Build outputs
8+
dist/
9+
build/
10+
.next/
11+
out/
12+
13+
# Cache
14+
.cache/
15+
.turbo/
16+
17+
# Logs
18+
*.log
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
23+
# Environment files
24+
.env
25+
.env.local
26+
.env.*.local
27+
28+
# Coverage
29+
coverage/
30+
.nyc_output/
31+
32+
# Misc
33+
.DS_Store
34+
*.pem
35+
36+
# Config files
37+
*.config.js
38+
*.config.mjs

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": false,
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "auto"
10+
}

.releaserc.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919
[
2020
"@semantic-release/git",
2121
{
22-
"assets": [
23-
"CHANGELOG.md",
24-
"package.json",
25-
"package-lock.json",
26-
"src/version.ts"
27-
],
22+
"assets": ["CHANGELOG.md", "package.json", "package-lock.json", "src/version.ts"],
2823
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
2924
}
3025
],

CHANGELOG.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,80 +14,69 @@
1414

1515
## [1.3.1](https://github.com/typelets/typelets-api/compare/v1.3.0...v1.3.1) (2025-09-25)
1616

17-
1817
### Bug Fixes
1918

20-
* enforce encrypted data validation to prevent plaintext exposure ([0cc6f77](https://github.com/typelets/typelets-api/commit/0cc6f77fcbf9def845e1fae0b871c27f7b1fad95))
19+
- enforce encrypted data validation to prevent plaintext exposure ([0cc6f77](https://github.com/typelets/typelets-api/commit/0cc6f77fcbf9def845e1fae0b871c27f7b1fad95))
2120

2221
# [1.3.0](https://github.com/typelets/typelets-api/compare/v1.2.0...v1.3.0) (2025-09-23)
2322

24-
2523
### Features
2624

27-
* add comprehensive Sentry monitoring and fix 429 rate limiting error ([6ba5744](https://github.com/typelets/typelets-api/commit/6ba5744022d075216e8053b6c2127cbb38a4824e))
25+
- add comprehensive Sentry monitoring and fix 429 rate limiting error ([6ba5744](https://github.com/typelets/typelets-api/commit/6ba5744022d075216e8053b6c2127cbb38a4824e))
2826

2927
# [1.2.0](https://github.com/typelets/typelets-api/compare/v1.1.1...v1.2.0) (2025-09-20)
3028

31-
3229
### Features
3330

34-
* **ci:** add Husky pre-commit hooks to prevent CI failures ([346bc2b](https://github.com/typelets/typelets-api/commit/346bc2bcd087d5000b7cc21032561c60baf43dda))
35-
* **ci:** add Husky pre-commit hooks to prevent CI failures ([e2b1017](https://github.com/typelets/typelets-api/commit/e2b1017d1bbb133dd1067ef9234fb463ad89f15d))
36-
* **code:** add secure API proxy for code execution ([8d599b5](https://github.com/typelets/typelets-api/commit/8d599b5c6c72e3ae871a9cf71b9304fb8541828e))
31+
- **ci:** add Husky pre-commit hooks to prevent CI failures ([346bc2b](https://github.com/typelets/typelets-api/commit/346bc2bcd087d5000b7cc21032561c60baf43dda))
32+
- **ci:** add Husky pre-commit hooks to prevent CI failures ([e2b1017](https://github.com/typelets/typelets-api/commit/e2b1017d1bbb133dd1067ef9234fb463ad89f15d))
33+
- **code:** add secure API proxy for code execution ([8d599b5](https://github.com/typelets/typelets-api/commit/8d599b5c6c72e3ae871a9cf71b9304fb8541828e))
3734

3835
## [1.1.1](https://github.com/typelets/typelets-api/compare/v1.1.0...v1.1.1) (2025-09-16)
3936

40-
4137
### Bug Fixes
4238

43-
* make note title field optional for encrypted notes ([ec19a48](https://github.com/typelets/typelets-api/commit/ec19a48954a10eb2a2531c3195fc5fe6b3430d70))
39+
- make note title field optional for encrypted notes ([ec19a48](https://github.com/typelets/typelets-api/commit/ec19a48954a10eb2a2531c3195fc5fe6b3430d70))
4440

4541
# [1.1.0](https://github.com/typelets/typelets-api/compare/v1.0.4...v1.1.0) (2025-09-15)
4642

47-
4843
### Features
4944

50-
* **websocket:** implement real-time sync with HMAC authentication and fix folder moves ([8de85b7](https://github.com/typelets/typelets-api/commit/8de85b7eae38b9af76154e40cdeff53d771f6e92))
45+
- **websocket:** implement real-time sync with HMAC authentication and fix folder moves ([8de85b7](https://github.com/typelets/typelets-api/commit/8de85b7eae38b9af76154e40cdeff53d771f6e92))
5146

5247
## [1.0.4](https://github.com/typelets/typelets-api/compare/v1.0.3...v1.0.4) (2025-09-10)
5348

54-
5549
### Bug Fixes
5650

57-
* bundle API with esbuild to resolve directory import errors ([4644c0e](https://github.com/typelets/typelets-api/commit/4644c0e3d2de2eb5796abab36b931615dc81eead))
51+
- bundle API with esbuild to resolve directory import errors ([4644c0e](https://github.com/typelets/typelets-api/commit/4644c0e3d2de2eb5796abab36b931615dc81eead))
5852

5953
## [1.0.3](https://github.com/typelets/typelets-api/compare/v1.0.2...v1.0.3) (2025-09-10)
6054

61-
6255
### Bug Fixes
6356

64-
* include root-level TypeScript files in esbuild output ([cf9bb4f](https://github.com/typelets/typelets-api/commit/cf9bb4fda0fa19925122b816d0375c88c4f39e05))
57+
- include root-level TypeScript files in esbuild output ([cf9bb4f](https://github.com/typelets/typelets-api/commit/cf9bb4fda0fa19925122b816d0375c88c4f39e05))
6558

6659
## [1.0.2](https://github.com/typelets/typelets-api/compare/v1.0.1...v1.0.2) (2025-09-10)
6760

68-
6961
### Bug Fixes
7062

71-
* replace tsc with esbuild to resolve build hanging issue ([235fce7](https://github.com/typelets/typelets-api/commit/235fce77cdde4e2287fe8b25acc7bcb96deb6ff8))
63+
- replace tsc with esbuild to resolve build hanging issue ([235fce7](https://github.com/typelets/typelets-api/commit/235fce77cdde4e2287fe8b25acc7bcb96deb6ff8))
7264

7365
## [1.0.1](https://github.com/typelets/typelets-api/compare/v1.0.0...v1.0.1) (2025-09-10)
7466

75-
7667
### Bug Fixes
7768

78-
* update Dockerfile to use pnpm instead of npm ([13e9639](https://github.com/typelets/typelets-api/commit/13e963965c7e5fa0e060ba8a0d8995eee761620b))
69+
- update Dockerfile to use pnpm instead of npm ([13e9639](https://github.com/typelets/typelets-api/commit/13e963965c7e5fa0e060ba8a0d8995eee761620b))
7970

8071
# 1.0.0 (2025-09-09)
8172

82-
8373
### Bug Fixes
8474

85-
* remove ES module configuration to fix semantic-release scripts ([f869d14](https://github.com/typelets/typelets-api/commit/f869d14cf42b35d119d11e3e25daff98060b7129))
86-
75+
- remove ES module configuration to fix semantic-release scripts ([f869d14](https://github.com/typelets/typelets-api/commit/f869d14cf42b35d119d11e3e25daff98060b7129))
8776

8877
### Features
8978

90-
* initial open source release of Typelets API ([66a3d30](https://github.com/typelets/typelets-api/commit/66a3d30dcbc0a33c4118c6948d9537e885298039))
79+
- initial open source release of Typelets API ([66a3d30](https://github.com/typelets/typelets-api/commit/66a3d30dcbc0a33c4118c6948d9537e885298039))
9180

9281
# Changelog
9382

0 commit comments

Comments
 (0)