@sepo27/servicio 0.5.0 → 0.6.1

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,3 +1,11 @@
1
+ ## <small>0.6.1 (2026-12-05)</small>
2
+
3
+ * docs: Update README ([377d0af](https://github.com/sepo27/servicio/commit/377d0af))
4
+
5
+ ## 0.6.0 (2026-12-05)
6
+
7
+ * feat: Extend makeRouter() to support options ([b9aa465](https://github.com/sepo27/servicio/commit/b9aa465))
8
+
1
9
  ## 0.5.0 (2026-12-05)
2
10
 
3
11
  * refaactor: Refactor complete approach to use namespace solution ([4006cd3](https://github.com/sepo27/servicio/commit/4006cd3))
package/README.md CHANGED
@@ -9,8 +9,8 @@ Backend Service Frame.
9
9
 
10
10
  **Features:**
11
11
  - lightweight *(as express JS itself)*
12
- - reusable routes abstraction
13
- - simplified router actions (with returning responses)
12
+ - reusable routes & routers
13
+ - route actions with returnable responses
14
14
 
15
15
  # Quick Start
16
16
 
@@ -90,7 +90,7 @@ router.useRoute('GET /', () => new SuccessResponse({
90
90
  },
91
91
  }))
92
92
 
93
- const fooItemsRouter: svc.Router = svc.router('/:id/items')
93
+ const fooItemsRouter: svc.Router = svc.router('/:id/items', { mergeParams: true })
94
94
  fooItemsRouter.useRoute('GET /', () => new SuccessResponse({
95
95
  status: HttpStatus.OK,
96
96
  body: {
@@ -103,8 +103,9 @@ router.useRouter(fooItemsRouter)
103
103
  app.useRouter(router)
104
104
  ```
105
105
 
106
- **:warning: A bug is present where path params are missing in nested routers' actions / handlers**
107
- **:warning: Presently "mixin" objects' methods (`App` / `Router`) do not support chaining**
106
+ *:information_source: Mind `mergeParams` option to handle params in sub-routers (see [here](https://expressjs.com/en/5x/guide/routing/#expressrouter))*
107
+
108
+ :information_source: Servicio does not currently support chainable methods (due to mixin proxy complexity)
108
109
 
109
110
  ## Express JS wrapper
110
111
 
@@ -5,7 +5,7 @@ export declare namespace svc {
5
5
  const app: () => AppType;
6
6
  const route: (endpoint: import("./main/types.js").RouteEndpointParam, action: import("./main/types.js").RouteAction) => RouteClass;
7
7
  const Route: typeof RouteClass;
8
- const router: (path: string) => RouterType;
8
+ const router: (path: string, options?: import("express").RouterOptions) => RouterType;
9
9
  type App = AppType;
10
10
  type Route = RouteClass;
11
11
  type Router = RouterType;
@@ -1,2 +1,3 @@
1
+ import express from 'express';
1
2
  import type { Router } from '../routing/Router.js';
2
- export declare const makeRouter: (path: string) => Router;
3
+ export declare const makeRouter: (path: string, options?: express.RouterOptions) => Router;
@@ -1,7 +1,7 @@
1
1
  import express from 'express';
2
2
  import { RouterX } from '../routing/RouterX.js';
3
3
  import { mixinProxy } from './mixinProxy.js';
4
- export const makeRouter = (path) => {
5
- const irouter = express.Router();
4
+ export const makeRouter = (path, options) => {
5
+ const irouter = express.Router(options);
6
6
  return mixinProxy(new RouterX(path, irouter), irouter);
7
7
  };
@@ -14,11 +14,19 @@ describe('makeRouter()', () => {
14
14
  });
15
15
  it('creates a router by combining RouterX with Express and returns the proxy', () => {
16
16
  const path = '/foo', irouter = bench.mock.express.getRoutable(), router = {};
17
- const expressRouterMock = jest.spyOn(express, 'Router').mockReturnValue(irouter), mixinProxyMock = jest.spyOn(mixinProxyModule, 'mixinProxy').mockReturnValue(router);
17
+ const expressRouterFactoryMock = jest.spyOn(express, 'Router').mockReturnValue(irouter), mixinProxyMock = jest.spyOn(mixinProxyModule, 'mixinProxy').mockReturnValue(router);
18
18
  expect(makeRouter(path)).toBe(router);
19
- expect(expressRouterMock).toHaveBeenCalledTimes(1);
19
+ expect(expressRouterFactoryMock).toHaveBeenCalledTimes(1);
20
20
  expect(mixinProxyMock).toHaveBeenCalledTimes(1);
21
21
  expect(mixinProxyMock).toHaveBeenCalledWith(expect.any(RouterX), irouter);
22
22
  expect(mixinProxyMock).toHaveBeenCalledWith(expect.objectContaining({ path }), irouter);
23
23
  });
24
+ it('creates a router without options', () => {
25
+ const opts = { mergeParams: true };
26
+ const expressRouterFactoryMock = jest.spyOn(express, 'Router');
27
+ jest.spyOn(mixinProxyModule, 'mixinProxy');
28
+ makeRouter('/foo', opts);
29
+ expect(expressRouterFactoryMock).toHaveBeenCalledTimes(1);
30
+ expect(expressRouterFactoryMock).toHaveBeenCalledWith(opts);
31
+ });
24
32
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sepo27/servicio",
3
3
  "description": "Backend Service Frame",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
7
7
  "types": "./dist/src/index.d.ts",