@veloxts/core 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @veloxts/core
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat(router): add raw() response primitive for redirects, cookies, custom headers and .check() post-middleware authorization primitive
8
+
9
+ ### Patch Changes
10
+
11
+ - ca6ede3: Plugin contract fixes — eliminates three workaround `addHook` blocks freehand projects need to write today.
12
+ - **`@veloxts/orm`**: `ctx.db` is now writable so middleware (e.g. transactional handlers) can swap in a tx client via `Object.assign(ctx, { db: tx })` without redefining the property.
13
+ - **`@veloxts/core`**: registers an empty-JSON-body fallback parser at app construction. POSTs with `Content-Type: application/json` and empty body now reach handlers as `input = {}` instead of being rejected with 400 by Fastify's default parser.
14
+ - **`@veloxts/events`, `@veloxts/cache`, `@veloxts/mail`, `@veloxts/queue`, `@veloxts/storage`**: each plugin now mirrors its `request.<name>` decoration onto the procedure context (`request.context.<name>`), matching the existing auth-plugin pattern. `ctx.events`, `ctx.cache`, `ctx.mail`, `ctx.queue`, `ctx.storage` are now populated automatically — no manual bridging hook required.
15
+
16
+ **Behavior changes to be aware of on upgrade:**
17
+ - `@veloxts/core` now registers an `application/json` content-type parser by default. If you previously called `app.server.addContentTypeParser('application/json', ...)` in user code, you will now hit `FST_ERR_CTP_ALREADY_PRESENT`. Call `app.server.removeContentTypeParser('application/json')` first, then register your own parser.
18
+ - `ctx.db` was previously frozen via `Object.defineProperty({ writable: false })`. Library authors who relied on the strict-mode TypeError on reassignment should switch to defensive copying (`{ ...ctx }`) instead. End-user procedures and middleware are unaffected.
19
+
20
+ ## 0.8.3
21
+
22
+ ### Patch Changes
23
+
24
+ - bump dependencies across packages (April 2026)
25
+
3
26
  ## 0.8.2
4
27
 
5
28
  ### Patch Changes
package/dist/app.js CHANGED
@@ -10,6 +10,7 @@ import { ConflictError, isVeloxError, VeloxError } from './errors.js';
10
10
  import { isVeloxModule } from './module/define-module.js';
11
11
  import { createModulePlugin } from './module/register.js';
12
12
  import { isFastifyPlugin, isVeloxPlugin, validatePluginMetadata } from './plugin.js';
13
+ import { setupEmptyBodyParser } from './plugins/empty-body-parser.js';
13
14
  import { requestLogger } from './plugins/request-logger.js';
14
15
  import { registerStatic } from './plugins/static.js';
15
16
  import { printBanner } from './utils/banner.js';
@@ -61,6 +62,7 @@ export class VeloxApp {
61
62
  });
62
63
  this._lifecycle = new LifecycleManager();
63
64
  setupContextHook(this._server);
65
+ setupEmptyBodyParser(this._server);
64
66
  this._setupErrorHandling();
65
67
  this._lifecycle.setupSignalHandlers(async () => {
66
68
  await this.stop();
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Empty-body-tolerant JSON parser
3
+ *
4
+ * Fastify's default `application/json` parser rejects empty bodies with a 400.
5
+ * The Velox client sends `Content-Type: application/json` with an empty body
6
+ * for input-less mutations, which would otherwise fail before reaching the
7
+ * procedure pipeline. This parser returns `{}` for empty bodies and delegates
8
+ * to `JSON.parse` for everything else.
9
+ *
10
+ * Registered automatically by the VeloxApp constructor. Users who need a
11
+ * different parser can call `server.removeContentTypeParser('application/json')`
12
+ * before registering their own.
13
+ *
14
+ * @module plugins/empty-body-parser
15
+ */
16
+ import type { FastifyInstance } from 'fastify';
17
+ export declare function setupEmptyBodyParser(server: FastifyInstance): void;
@@ -0,0 +1,17 @@
1
+ export function setupEmptyBodyParser(server) {
2
+ server.addContentTypeParser('application/json', { parseAs: 'string' }, (_request, body, done) => {
3
+ const raw = typeof body === 'string' ? body.trim() : '';
4
+ if (raw === '') {
5
+ done(null, {});
6
+ return;
7
+ }
8
+ try {
9
+ done(null, JSON.parse(raw));
10
+ }
11
+ catch (error) {
12
+ const err = error;
13
+ err.statusCode = 400;
14
+ done(err);
15
+ }
16
+ });
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/core",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Fastify wrapper and plugin system for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "fastify": "5.8.2",
32
+ "fastify": "5.8.5",
33
33
  "fastify-plugin": "5.1.0",
34
34
  "picocolors": "1.1.1"
35
35
  },
@@ -42,11 +42,11 @@
42
42
  }
43
43
  },
44
44
  "devDependencies": {
45
- "@fastify/static": "9.0.0",
46
- "@types/node": "25.5.0",
47
- "@vitest/coverage-v8": "4.1.0",
45
+ "@fastify/static": "9.1.3",
46
+ "@types/node": "25.6.0",
47
+ "@vitest/coverage-v8": "4.1.5",
48
48
  "typescript": "5.9.3",
49
- "vitest": "4.1.0"
49
+ "vitest": "4.1.5"
50
50
  },
51
51
  "keywords": [
52
52
  "velox",