Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
288 commits
Select commit Hold shift + click to select a range
b7ce05b
update note schemas
tryb3l Jan 7, 2025
f24daf2
update user schemas
tryb3l Jan 7, 2025
e473cbe
update schemas to include JSON Schema draft-07 and add required prope…
tryb3l Jan 7, 2025
d21a654
add error handling for note retrieval; update user role in setup; imp…
tryb3l Jan 7, 2025
2477294
remove debug leftover files
tryb3l Mar 18, 2026
e8b01a8
update dependencies
tryb3l Mar 18, 2026
a5f9085
refactored plugins, enhanced token verification and error handlings. …
tryb3l Mar 18, 2026
77e396d
update endpoints, route methods
tryb3l Mar 18, 2026
b3b56c4
refactor schemas
tryb3l Mar 18, 2026
8c94683
updated endpoints, added custom rate limiters
tryb3l Mar 18, 2026
b2e5b57
updated exception handlers for specific endpoints, schema refs etc
tryb3l Mar 18, 2026
8322b1b
added graceful shutdown for `app.js`
tryb3l Mar 18, 2026
c11f2ef
added auth tweaks in swagger plugin
tryb3l Mar 18, 2026
ddf1f51
update dependencies
tryb3l Mar 22, 2026
9dc6a02
fix note data source usage in route handlers
tryb3l Mar 22, 2026
edad53b
update Mongo docker image, enhance test setup with improved logging a…
tryb3l Mar 22, 2026
6843ffc
remove debug leftovers
tryb3l Mar 22, 2026
5af0ced
refactor `routes` to use `fastify.notesDataSource` and add data wrap…
tryb3l Mar 22, 2026
9b675c7
small tweaks
tryb3l Mar 22, 2026
93f8b83
refactor tests, use node test runner
tryb3l Mar 22, 2026
acf5974
unskip tests
tryb3l Mar 22, 2026
d0c5a3f
Add more test cases, data generators etc
tryb3l Mar 22, 2026
08cfe78
refactor `login` tests to use node:test and improve assertions
tryb3l Mar 23, 2026
b22f71a
refactor tests, use node runner, add more TC's
tryb3l Mar 23, 2026
b81e08d
refactor tests, add more TC's
tryb3l Mar 23, 2026
246f554
refactor tests
tryb3l Mar 23, 2026
4e63091
refactor tests. fix `updatenote` issue
tryb3l Mar 23, 2026
bfce0b4
extend assertions
tryb3l Mar 23, 2026
b5a94e8
add test
tryb3l Mar 23, 2026
ea4b878
refactor data-creator and setup-user: replace generateKey with fastGe…
tryb3l Mar 23, 2026
628f359
move file
tryb3l Mar 23, 2026
b178c69
refactor logger test and logger prefs file
tryb3l Mar 23, 2026
4b50088
refactor test
tryb3l Mar 23, 2026
0f6a319
refactor crypto stuff, add unit tests
tryb3l Mar 23, 2026
5e68b90
update CI config
tryb3l Mar 23, 2026
f2c43bc
drop `tap`, add `caching`& `form-data`
tryb3l Mar 23, 2026
5e9510f
small tweaks
tryb3l Mar 23, 2026
642f14e
add LRU cache, rate-limit, and under-pressure plugins with configurat…
tryb3l Mar 23, 2026
e0fd285
add tests for the health checks, rate limiting, and file operations
tryb3l Mar 26, 2026
fbe9fb5
move docker and compose files to the root level. Add caged node image…
tryb3l Mar 26, 2026
9f447e8
makefile and scripts improvements
tryb3l Mar 26, 2026
b3edea7
update dotenv structure
tryb3l Mar 26, 2026
5117282
add decorators to `cookie`, `notes-store`, `rate-limit`, and `swagger…
tryb3l Mar 28, 2026
06a4963
add `compress` plugin and update package dependencies
tryb3l Mar 28, 2026
ae2e40d
replace console logs with fastify logger in `application-config` plugin
tryb3l Mar 28, 2026
f84e5a6
refactor `tracing` configuration for `OpenTelemetry` SDK and improve …
tryb3l Mar 28, 2026
a77eb34
add decorators section to `authentication` plugin configuration
tryb3l Mar 28, 2026
eab7386
update `CORS` plugin to use allowed origins from config
tryb3l Mar 28, 2026
4b16d49
refactor `db-plugin` to use fastify logger and update MongoDB connect…
tryb3l Mar 28, 2026
041909e
refactor `helmet` plugin to improve registration and remove commented…
tryb3l Mar 28, 2026
cf7f53a
add `seed` plugin for initial database seeding and refactor `user aut…
tryb3l Mar 28, 2026
4c2dd77
add decorators to `under-pressure` plugin for MongoDB access
tryb3l Mar 28, 2026
4edf7c6
refactor `run-tests` to support node runners coverage and no-stop opt…
tryb3l Mar 28, 2026
5db3879
refactor `generate-hash` to improve code structure and remove unneces…
tryb3l Mar 28, 2026
a150817
fix user setup & tests
tryb3l Mar 28, 2026
7011657
refactor `authentication` error handling and update `registration` sc…
tryb3l Mar 28, 2026
d162c74
add .env and .idea to .gitignore
tryb3l Mar 28, 2026
0dd6c22
refactor .gitignore to clean up unused entries and maintain necessary…
tryb3l Mar 28, 2026
8f7db9d
refactor CI workflow to use secrets for JWT and cookie secrets
tryb3l Mar 28, 2026
18f7736
drop `tap` leftovers
tryb3l Mar 28, 2026
2251669
update dependencies in `package.json`
tryb3l Mar 29, 2026
6ea0272
refactor `auth` plugin: simplify token extraction and error handling
tryb3l Mar 29, 2026
2c15e55
refactor `cors` plugin: expand allowed headers for CORS configuration
tryb3l Mar 29, 2026
315aae5
add `CSRF` protection plugin with conf
tryb3l Mar 29, 2026
88fec53
tweaks in `seed` plugin, renamings & clean up
tryb3l Mar 29, 2026
73d6955
refactor `users` plugin: implement soft delete logic and fix err hand…
tryb3l Mar 29, 2026
1e29293
tighten hashing, and validation by switching to ARGON2
tryb3l Mar 29, 2026
b0740da
update `auth` routes: update password handling, add `CSRF` protection…
tryb3l Mar 29, 2026
3da6b3c
add additionalProperties constraint to `authenticate` schema
tryb3l Mar 29, 2026
5e55912
refactor routes: replace '/health' endpoint with '/ready' for readine…
tryb3l Mar 29, 2026
2268664
add additionalProperties constraint to `list-query` schema
tryb3l Mar 29, 2026
5066c88
enhance file upload: validate file types and use UUID
tryb3l Mar 29, 2026
636bd06
update JWT expiration time
tryb3l Mar 29, 2026
604f838
refactor authentication tests and setup: retrieve refresh token from …
tryb3l Mar 29, 2026
43f1c06
add uploads
tryb3l Mar 29, 2026
9a59ce6
add username field to default admin account seeding
tryb3l Mar 29, 2026
3fd55a4
solve event loop problem
tryb3l Mar 29, 2026
6e8f72a
refactor `file upload` test: update status code and response handling
tryb3l Mar 29, 2026
ddea231
wrap admin account insertion in try-catch for error handling
tryb3l Mar 29, 2026
55a8dec
update `CORS` allowedHeaders and modify `auth` routes response schema
tryb3l Mar 29, 2026
87e38ab
add integration tests for CSRF protection, header-only model, logout,…
tryb3l Mar 29, 2026
adcaa04
add migration step to dev environment setup in makefile
tryb3l Mar 29, 2026
07e7688
simplify structure and update to use recommended settings
tryb3l Mar 29, 2026
2c4c616
add migration setup and live notes WebSocket functionality
tryb3l Mar 29, 2026
c83b929
update CI workflow
tryb3l Mar 29, 2026
1ef78c5
update logger options and add websocket plugin with event bus support
tryb3l Mar 29, 2026
4b268d4
update fastify-metrics to version 13.1.0
tryb3l Apr 3, 2026
433f701
implement audit logging, password complexity, cache invalidation, and…
tryb3l Apr 5, 2026
6fa01c1
implement audit logging, cache invalidation, and performance indexing…
tryb3l Apr 5, 2026
047f3a5
implement audit logging and automated cache invalidation, and restric…
tryb3l Apr 5, 2026
63f3759
implement file attachments, fix pagination defaults, and add audit an…
tryb3l Apr 5, 2026
91bc7bb
improve cache invalidation logic to include `POST` requests and impro…
tryb3l Apr 5, 2026
41edd55
add expires_in field to access token response, implement file downloa…
tryb3l Apr 5, 2026
a4b6bf2
add integration tests for user and note deletion, user update, and fi…
tryb3l Apr 5, 2026
1afb0d6
add nodemailer dependency for email handling
tryb3l Apr 6, 2026
39a717a
add mailer plugin for email handling and update config to include SMT…
tryb3l Apr 6, 2026
196b3fa
add migration for sparse password reset index and backfill credential…
tryb3l Apr 6, 2026
dfcc19d
add session invalidation checks for credentials version mismatch in a…
tryb3l Apr 6, 2026
a6a7b03
add password reset functionality with request, validation, and confir…
tryb3l Apr 6, 2026
f5c3a00
add credentialsVersion to user data and implement password reset meth…
tryb3l Apr 6, 2026
75261c0
add SMTP configuration properties to dotenv schema
tryb3l Apr 6, 2026
fd93f16
update fastify-metrics
tryb3l Apr 6, 2026
0ce23b2
- Updated header only authentication tests to clearly specify expecte…
tryb3l Apr 6, 2026
0fd9901
Implement password reset functionality with enhanced validation, cool…
tryb3l Apr 6, 2026
5c28c1d
Refactor password reset service calls to include request context. upd…
tryb3l Apr 6, 2026
3e0f944
improve test setup, add environment support and Mongo URL retrieval. …
tryb3l Apr 6, 2026
0cf62e9
Refactor test environment configuration to utilize environment variab…
tryb3l Apr 6, 2026
b4ea0c6
add cors test
tryb3l Sep 20, 2024
9542958
update cors plugin
tryb3l Sep 20, 2024
5ae9e69
update dependencies for @fastify/env, @fastify/mongodb, @fastify/rate…
tryb3l Sep 22, 2024
a8d4048
refactor CORS test to use 'test' instead of 'it' and pass context to …
tryb3l Sep 22, 2024
c92c501
add tests for notFoundHandler and rate limiting behavior
tryb3l Sep 22, 2024
59c1b76
enhance randomString function and add randomStringWithPrefix
tryb3l Sep 23, 2024
af6527a
add createNote utility function for note creation in tests
tryb3l Sep 23, 2024
f991225
refactor note creation and update logic to return note object and han…
tryb3l Sep 23, 2024
967c383
refactor note routes to return note object and improve error handling
tryb3l Sep 23, 2024
fb964ed
remove status field from update body schema in notes routes
tryb3l Sep 23, 2024
d2f07b5
update dependencies to latest versions in package.json
tryb3l Sep 23, 2024
20c8074
update dependencies
tryb3l Nov 28, 2024
56c6ca0
update eslint
tryb3l Nov 30, 2024
718a353
add script for the initial admin creation
tryb3l Nov 30, 2024
404f89b
add role field to user registration and user schemas
tryb3l Dec 1, 2024
1b9f0f0
add eslint configuration file and remove mjs version
tryb3l Dec 1, 2024
8d21696
update globals package version to 15.13.0
tryb3l Dec 2, 2024
e9ffa3b
update @fastify/swagger-ui to version 5.2.0
tryb3l Dec 3, 2024
a7210de
update prettier to version 3.4.2
tryb3l Dec 5, 2024
c8edef9
add authentication and authorization features to the auth plugin
tryb3l Dec 13, 2024
ed5d0ef
update dependencies to latest versions
tryb3l Dec 20, 2024
322e37a
update dependencies to latest versions
tryb3l Dec 22, 2024
3117ee1
update fastify-cli to version 7.3.0
tryb3l Dec 23, 2024
8844ecc
add user list response schema and remove outdated schema
tryb3l Dec 24, 2024
bee6536
update mongo image version in docker to 8
tryb3l Dec 29, 2024
750e77f
add dev-debug script to package.json for enhanced debugging
tryb3l Jan 1, 2025
08312a8
update dependencies
tryb3l Jan 5, 2025
9c66f4b
small tweaks in package.json
tryb3l Jan 7, 2025
4dd9bd8
update plugins
tryb3l Jan 7, 2025
5cc4b4c
update app.js
tryb3l Jan 7, 2025
4f14e83
update .env
tryb3l Jan 7, 2025
7ac50d2
refactor autohooks and config
tryb3l Jan 7, 2025
a6b0710
update routes auth
tryb3l Jan 7, 2025
ce9d250
update auth schemas
tryb3l Jan 7, 2025
94588d2
update routes
tryb3l Jan 7, 2025
e3c8f0e
update note schemas
tryb3l Jan 7, 2025
e86fa89
update user schemas
tryb3l Jan 7, 2025
ac61223
update schemas to include JSON Schema draft-07 and add required prope…
tryb3l Jan 7, 2025
39cdcfd
add error handling for note retrieval; update user role in setup; imp…
tryb3l Jan 7, 2025
4ceed09
remove debug leftover files
tryb3l Mar 18, 2026
79a38f7
update dependencies
tryb3l Mar 18, 2026
8f8a437
refactored plugins, enhanced token verification and error handlings. …
tryb3l Mar 18, 2026
7c489bc
update endpoints, route methods
tryb3l Mar 18, 2026
943006e
refactor schemas
tryb3l Mar 18, 2026
500f10b
updated endpoints, added custom rate limiters
tryb3l Mar 18, 2026
ebe636a
updated exception handlers for specific endpoints, schema refs etc
tryb3l Mar 18, 2026
e539d3b
added graceful shutdown for `app.js`
tryb3l Mar 18, 2026
f74f00e
added auth tweaks in swagger plugin
tryb3l Mar 18, 2026
ea96e34
update dependencies
tryb3l Mar 22, 2026
155de00
fix note data source usage in route handlers
tryb3l Mar 22, 2026
d00452c
update Mongo docker image, enhance test setup with improved logging a…
tryb3l Mar 22, 2026
ab57eb4
remove debug leftovers
tryb3l Mar 22, 2026
8e62cfd
refactor `routes` to use `fastify.notesDataSource` and add data wrap…
tryb3l Mar 22, 2026
aa5961c
small tweaks
tryb3l Mar 22, 2026
483f4a4
refactor tests, use node test runner
tryb3l Mar 22, 2026
b77ffc1
unskip tests
tryb3l Mar 22, 2026
647cb60
Add more test cases, data generators etc
tryb3l Mar 22, 2026
27bc96e
refactor `login` tests to use node:test and improve assertions
tryb3l Mar 23, 2026
75d6780
refactor tests, use node runner, add more TC's
tryb3l Mar 23, 2026
74da2c0
refactor tests, add more TC's
tryb3l Mar 23, 2026
211039d
refactor tests
tryb3l Mar 23, 2026
43baeb5
refactor tests. fix `updatenote` issue
tryb3l Mar 23, 2026
8a4c0e5
extend assertions
tryb3l Mar 23, 2026
941f6fd
add test
tryb3l Mar 23, 2026
087ffe5
refactor data-creator and setup-user: replace generateKey with fastGe…
tryb3l Mar 23, 2026
d4f4c33
move file
tryb3l Mar 23, 2026
997d4bf
refactor logger test and logger prefs file
tryb3l Mar 23, 2026
5717ba4
refactor test
tryb3l Mar 23, 2026
ec0a229
refactor crypto stuff, add unit tests
tryb3l Mar 23, 2026
3e70d3b
update CI config
tryb3l Mar 23, 2026
faf8e9c
drop `tap`, add `caching`& `form-data`
tryb3l Mar 23, 2026
622ae93
small tweaks
tryb3l Mar 23, 2026
9d93c7d
add LRU cache, rate-limit, and under-pressure plugins with configurat…
tryb3l Mar 23, 2026
ed6d264
add tests for the health checks, rate limiting, and file operations
tryb3l Mar 26, 2026
1ca7bca
move docker and compose files to the root level. Add caged node image…
tryb3l Mar 26, 2026
450c9bf
makefile and scripts improvements
tryb3l Mar 26, 2026
0021844
update dotenv structure
tryb3l Mar 26, 2026
20f799a
add decorators to `cookie`, `notes-store`, `rate-limit`, and `swagger…
tryb3l Mar 28, 2026
09b455e
add `compress` plugin and update package dependencies
tryb3l Mar 28, 2026
d0ecb07
replace console logs with fastify logger in `application-config` plugin
tryb3l Mar 28, 2026
d2f730a
refactor `tracing` configuration for `OpenTelemetry` SDK and improve …
tryb3l Mar 28, 2026
b6ca612
add decorators section to `authentication` plugin configuration
tryb3l Mar 28, 2026
22bef10
update `CORS` plugin to use allowed origins from config
tryb3l Mar 28, 2026
f33bf9b
refactor `db-plugin` to use fastify logger and update MongoDB connect…
tryb3l Mar 28, 2026
6f3a8c9
refactor `helmet` plugin to improve registration and remove commented…
tryb3l Mar 28, 2026
0093102
add `seed` plugin for initial database seeding and refactor `user aut…
tryb3l Mar 28, 2026
708613f
add decorators to `under-pressure` plugin for MongoDB access
tryb3l Mar 28, 2026
44c961d
refactor `run-tests` to support node runners coverage and no-stop opt…
tryb3l Mar 28, 2026
40c2d52
refactor `generate-hash` to improve code structure and remove unneces…
tryb3l Mar 28, 2026
e952dd7
fix user setup & tests
tryb3l Mar 28, 2026
07cfacc
refactor `authentication` error handling and update `registration` sc…
tryb3l Mar 28, 2026
94f3175
add .env and .idea to .gitignore
tryb3l Mar 28, 2026
6f979df
refactor .gitignore to clean up unused entries and maintain necessary…
tryb3l Mar 28, 2026
fc6db2a
refactor CI workflow to use secrets for JWT and cookie secrets
tryb3l Mar 28, 2026
6d82c0d
drop `tap` leftovers
tryb3l Mar 28, 2026
6d58754
update dependencies in `package.json`
tryb3l Mar 29, 2026
59abeb2
refactor `auth` plugin: simplify token extraction and error handling
tryb3l Mar 29, 2026
16cf1a1
refactor `cors` plugin: expand allowed headers for CORS configuration
tryb3l Mar 29, 2026
d4cc2fb
add `CSRF` protection plugin with conf
tryb3l Mar 29, 2026
1dfd884
tweaks in `seed` plugin, renamings & clean up
tryb3l Mar 29, 2026
a8c0cf7
refactor `users` plugin: implement soft delete logic and fix err hand…
tryb3l Mar 29, 2026
ac9a375
tighten hashing, and validation by switching to ARGON2
tryb3l Mar 29, 2026
1c91b23
update `auth` routes: update password handling, add `CSRF` protection…
tryb3l Mar 29, 2026
52df6c9
add additionalProperties constraint to `authenticate` schema
tryb3l Mar 29, 2026
c4d03f1
refactor routes: replace '/health' endpoint with '/ready' for readine…
tryb3l Mar 29, 2026
49bbaee
add additionalProperties constraint to `list-query` schema
tryb3l Mar 29, 2026
046db12
enhance file upload: validate file types and use UUID
tryb3l Mar 29, 2026
fb03432
update JWT expiration time
tryb3l Mar 29, 2026
0220df4
refactor authentication tests and setup: retrieve refresh token from …
tryb3l Mar 29, 2026
501b573
add uploads
tryb3l Mar 29, 2026
68d16a4
add username field to default admin account seeding
tryb3l Mar 29, 2026
55c46a5
solve event loop problem
tryb3l Mar 29, 2026
9892d22
refactor `file upload` test: update status code and response handling
tryb3l Mar 29, 2026
16e633e
wrap admin account insertion in try-catch for error handling
tryb3l Mar 29, 2026
4c57222
update `CORS` allowedHeaders and modify `auth` routes response schema
tryb3l Mar 29, 2026
1429337
add integration tests for CSRF protection, header-only model, logout,…
tryb3l Mar 29, 2026
1d5ab2c
add migration step to dev environment setup in makefile
tryb3l Mar 29, 2026
08d4641
simplify structure and update to use recommended settings
tryb3l Mar 29, 2026
758aed0
add migration setup and live notes WebSocket functionality
tryb3l Mar 29, 2026
0e196b3
update CI workflow
tryb3l Mar 29, 2026
a54a6ca
update logger options and add websocket plugin with event bus support
tryb3l Mar 29, 2026
bec4b2a
update fastify-metrics to version 13.1.0
tryb3l Apr 3, 2026
cc74a90
implement audit logging, password complexity, cache invalidation, and…
tryb3l Apr 5, 2026
5cb68f1
implement audit logging, cache invalidation, and performance indexing…
tryb3l Apr 5, 2026
2263389
implement audit logging and automated cache invalidation, and restric…
tryb3l Apr 5, 2026
dc66ce5
implement file attachments, fix pagination defaults, and add audit an…
tryb3l Apr 5, 2026
3541ac7
improve cache invalidation logic to include `POST` requests and impro…
tryb3l Apr 5, 2026
4380ca0
add expires_in field to access token response, implement file downloa…
tryb3l Apr 5, 2026
f66d01f
add integration tests for user and note deletion, user update, and fi…
tryb3l Apr 5, 2026
ebee30d
add nodemailer dependency for email handling
tryb3l Apr 6, 2026
e4c931d
add mailer plugin for email handling and update config to include SMT…
tryb3l Apr 6, 2026
cd4b2b1
add migration for sparse password reset index and backfill credential…
tryb3l Apr 6, 2026
8eb6444
add session invalidation checks for credentials version mismatch in a…
tryb3l Apr 6, 2026
dec7a4c
add password reset functionality with request, validation, and confir…
tryb3l Apr 6, 2026
3e567b6
add credentialsVersion to user data and implement password reset meth…
tryb3l Apr 6, 2026
6b4437d
add SMTP configuration properties to dotenv schema
tryb3l Apr 6, 2026
147dd95
update fastify-metrics
tryb3l Apr 6, 2026
cf6a48c
- Updated header only authentication tests to clearly specify expecte…
tryb3l Apr 6, 2026
b813b7d
Implement password reset functionality with enhanced validation, cool…
tryb3l Apr 6, 2026
994a46a
Refactor password reset service calls to include request context. upd…
tryb3l Apr 6, 2026
77d348b
improve test setup, add environment support and Mongo URL retrieval. …
tryb3l Apr 6, 2026
d7f2441
Refactor test environment configuration to utilize environment variab…
tryb3l Apr 6, 2026
68d3451
Merge remote-tracking branch 'origin/BT/unstable' into BT/unstable
tryb3l Apr 6, 2026
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
6 changes: 0 additions & 6 deletions .env

This file was deleted.

23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
name: CI
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

services:
mongodb:
image: mongo:8
ports:
- 27018:27017

env:
MONGO_URL: mongodb://127.0.0.1:27018/test
JWT_SECRET: ${{ secrets.JWT_SECRET }}
COOKIE_SECRET: ${{ secrets.COOKIE_SECRET }}
NODE_ENV: test

steps:
- name: Check out the source code
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v6
with:
node-version: '25'
check-latest: true

- name: Install dependencies
run: npm install
run: npm ci

- name: Run Database Migrations
run: npx migrate-mongo up

- name: Run tests
run: npm test
run: node --test test/**/*.test.js
19 changes: 6 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@ pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

#tap output
tap-*.log
.tap

#mongo logs
data

Expand All @@ -27,12 +20,6 @@ data
#test-results
**/test-results

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

Expand Down Expand Up @@ -69,3 +56,9 @@ profile-*
profile*
*clinic*
*flamegraph*

# env
.env

# uploads
uploads/
7 changes: 0 additions & 7 deletions .taprc

This file was deleted.

36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# --- Stage 1 build ---
FROM node:25-alpine AS builder

WORKDIR /build

COPY package.json package-lock.json ./

ARG NPM_TOKEN
RUN if [ -n "$NPM_TOKEN" ]; then echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc; fi && \
npm ci --omit=dev --ignore-scripts && \
rm -f .npmrc

# --- Stage 2 Prod runner ---
FROM platformatic/node-caged:25-alpine

RUN apk update && apk add --no-cache dumb-init

ENV HOME=/home/app
ENV APP_HOME=$HOME/node/
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-heap-size=1024"

RUN addgroup -S node && adduser -S node -G node

WORKDIR $APP_HOME

COPY --chown=node:node . $APP_HOME

COPY --chown=node:node --from=builder /build/node_modules $APP_HOME/node_modules

USER node

EXPOSE 3000

ENTRYPOINT ["dumb-init", "--"]
CMD ["./node_modules/.bin/fastify", "start", "-a", "0.0.0.0", "-l", "info", "--options", "app.js"]
102 changes: 51 additions & 51 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@ const path = require('node:path')
const AutoLoad = require('@fastify/autoload')
const closeWithGrace = require('close-with-grace')

// Pass --options via CLI arguments in command to enable these options.
const options = require('./configs/server-options.js')

module.exports = async function (fastify, opts) {
// Place here your custom code!
fastify.log.info('The .env file has been read %s', process.env.MONGO_URL)

fastify.register(AutoLoad, {
dir: path.join(__dirname, 'schemas'),
indexPattern: /^loader.js$/i,
})

await fastify.register(require('./plugins/config'))
fastify.log.info('Config loaded %o', fastify.config)

// Do not touch the following lines

// This loads all plugins defined in plugins
// those should be support plugins that are reused
// through your application
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
ignorePattern: /.*.no-load\.js/,
indexPattern: /^no$/i,
options: fastify.config,
})

// This loads all plugins defined in routes
// define your routes in one of these
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'routes'),
indexPattern: /.*routes(\.js|\.cjs)$/i,
ignorePattern: /.*\.js/,
autoHooksPattern: /.*hooks(\.js|\.cjs)$/i,
autoHooks: true,
cascadeHooks: true,
options: Object.assign({}, opts),
})

// Graceful shutdown handler
// eslint-disable-next-line no-unused-vars
closeWithGrace(async function ({ signal, err, manual }) {
if (err) {
fastify.log.error({ err }, 'server closing with error')
} else {
fastify.log.info(`${signal} received, server closing`)
}
await fastify.close()
})
}

module.exports.options = options
try {
// Register base schema
await require('./routes/auth/schemas/loader').authSchemasLoader(fastify)
await require('./routes/notes/schemas/loader').noteSchemasLoader(fastify)
await require('./routes/users/schemas/loader').loadUserSchemas(fastify)

// Load Config
await fastify.register(require('./plugins/config'), opts)

// Load Plugins
await fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
ignorePattern: /.*.no-load\.js/,
indexPattern: /^no$/i,
options: Object.assign({}, opts)
})

// Load Routes
await fastify.register(AutoLoad, {
dir: path.join(__dirname, 'routes'),
indexPattern: /.*routes(\.js|\.cjs)$/i,
ignorePattern: /(?:^|\/)(?:schemas|utils)(?:\/|$).*\.js/,
autoHooksPattern: /.*hooks(\.js|\.cjs)$/i,
autoHooks: true,
cascadeHooks: true,
options: Object.assign({}, opts)
})

const closeListeners = closeWithGrace(
{ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 },
async function ({ signal, err, manual }) {
if (err) {
fastify.log.error({ err }, 'Server closing due to error')
} else {
fastify.log.info(`${signal} received, gracefully shutting down server...`)
}

await fastify.close()
}
)

fastify.addHook('onClose', (instance, done) => {
closeListeners.uninstall()
done()
})

} catch (err) {
fastify.log.error(err)
throw err
}
}
17 changes: 7 additions & 10 deletions configs/logger-options.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
'use strict'
module.exports = {
level: process.env.LOG_LEVEL || 'info',
timestamp: () => {
const dateString = new Date(Date.now()).toISOString()
return `,"@timestamp":"${dateString}"`
},
timestamp: () => `,"time":"${new Date().toISOString()}"`,
redact: {
censor: '*****',
paths: ['req.headers.authorization', 'req.body.password', 'req.body.email'],
},
serializers: {
req: function (request) {
const shouldLogBody = request.context.config.logBody === true
const shouldLogBody = request.routeOptions?.config?.logBody === true
return {
method: request.method,
url: request.raw.url,
routeUrl: request.routePath,
routeUrl: request.routeOptions?.url ?? request.routePath,
version: request.headers?.['accept-version'],
user: request.user?.id,
user: request.user?._id || request.user?.id,
headers: request.headers,
body: shouldLogBody ? request.body : undefined,
hostname: request.hostname,
Expand All @@ -26,9 +23,9 @@ module.exports = {
}
},
res: function (reply) {
return {
statusCode: reply.statusCode,
responseTime: reply.getResponseTime(),
return {
statusCode: reply.statusCode,
responseTime: typeof reply.elapsedTime === 'number' ? reply.elapsedTime : undefined,
}
},
},
Expand Down
39 changes: 36 additions & 3 deletions configs/server-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,46 @@
const crypto = require('node:crypto')
const loggerOptions = require('./logger-options')

// W3C Trace Context: version(2)-trace_id(32)-parent_id(16)-flags(2)
const TRACEPARENT_RE = /^[\da-f]{2}-([\da-f]{32})-[\da-f]{16}-[\da-f]{2}$/

function extractTraceId(raw) {
if (!raw || typeof raw !== 'string') return null
const match = TRACEPARENT_RE.exec(raw)
return match ? match[1] : null
}

function sanitizeRequestId(value) {
if (!value || typeof value !== 'string') return null
// Cap at 128 chars to prevent memory abuse from oversized headers
if (value.length > 128) return null
return value
}

module.exports = {
disableRequestLogging: true,
logger: loggerOptions,
logger: {
...loggerOptions,
formatters: {
...loggerOptions.formatters,
log: (object) => {
if (object.reqId && object.reqId.length === 32 && /^[\da-f]{32}$/.test(object.reqId)) {
object.trace_id = object.reqId
}
return object
}
}
},
requestIdLogLabel: false,
requestIdHeader: 'x-request-id',
requestIdHeader: false,
pluginTimeout: 20000,
genReqId(req) {
return req.headers['x-amz-request-id'] || crypto.randomUUID()
const traceId = extractTraceId(req.headers['traceparent'])
if (traceId) return traceId

return sanitizeRequestId(req.headers['x-request-id'])
|| sanitizeRequestId(req.headers['x-amz-request-id'])
|| crypto.randomUUID()
},
ajv: {
customOptions: {
Expand Down
Loading