go-mokapi 0.51.0 → 0.51.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types/index.d.ts +19 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-mokapi",
3
- "version": "0.51.0",
3
+ "version": "0.51.1",
4
4
  "description": "Easy and flexible API mocking",
5
5
  "homepage": "https://mokapi.io",
6
6
  "repository": {
package/types/index.d.ts CHANGED
@@ -1524,6 +1524,14 @@ export interface ApiScope {
1524
1524
  * When multiple APIs share the same path, use `app.api()` to scope the router
1525
1525
  * to a specific API title to avoid unintended matches.
1526
1526
  *
1527
+ * All methods return `this`, enabling fluent chaining:
1528
+ * ```ts
1529
+ * app.http()
1530
+ * .use(authMiddleware)
1531
+ * .get(listHandler)
1532
+ * .post(createHandler)
1533
+ * ```
1534
+ *
1527
1535
  * All handlers registered on the same path and method run in registration order
1528
1536
  * (or by `priority` if specified). The last handler to write wins.
1529
1537
  *
@@ -1531,7 +1539,7 @@ export interface ApiScope {
1531
1539
  * // Shorthand style
1532
1540
  * import { app } from 'mokapi'
1533
1541
  * export default function() {
1534
- * const router = app.api('Petstore').http()
1542
+ * const router = app.http().api('Petstore')
1535
1543
  * router.get('/pets', (req, res) => { res.data = [] })
1536
1544
  * router.post('/pets', (req, res) => { res.statusCode = 201 })
1537
1545
  * }
@@ -1540,7 +1548,7 @@ export interface ApiScope {
1540
1548
  * // Chained style
1541
1549
  * import { app } from 'mokapi'
1542
1550
  * export default function() {
1543
- * app.api('Petstore').http()
1551
+ * app.http().api('Petstore')
1544
1552
  * .route('/pets')
1545
1553
  * .get((req, res) => { res.data = [] })
1546
1554
  * .post((req, res) => { res.statusCode = 201 })
@@ -1657,7 +1665,7 @@ export interface HttpRouter {
1657
1665
  * @example
1658
1666
  * app.http().get('/pets', (req, res) => { res.data = [] })
1659
1667
  */
1660
- get(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1668
+ get(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1661
1669
 
1662
1670
  /**
1663
1671
  * Registers a handler for `POST` requests to the given path.
@@ -1668,7 +1676,7 @@ export interface HttpRouter {
1668
1676
  * @example
1669
1677
  * app.http().post('/pets', (req, res) => { res.statusCode = 201 })
1670
1678
  */
1671
- post(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1679
+ post(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1672
1680
 
1673
1681
  /**
1674
1682
  * Registers a handler for `PUT` requests to the given path.
@@ -1676,7 +1684,7 @@ export interface HttpRouter {
1676
1684
  * @param handler The event handler to invoke.
1677
1685
  * @param opts Optional handler configuration such as priority and tracking.
1678
1686
  */
1679
- put(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1687
+ put(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1680
1688
 
1681
1689
  /**
1682
1690
  * Registers a handler for `PATCH` requests to the given path.
@@ -1684,7 +1692,7 @@ export interface HttpRouter {
1684
1692
  * @param handler The event handler to invoke.
1685
1693
  * @param opts Optional handler configuration such as priority and tracking.
1686
1694
  */
1687
- patch(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1695
+ patch(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1688
1696
 
1689
1697
  /**
1690
1698
  * Registers a handler for `DELETE` requests to the given path.
@@ -1692,7 +1700,7 @@ export interface HttpRouter {
1692
1700
  * @param handler The event handler to invoke.
1693
1701
  * @param opts Optional handler configuration such as priority and tracking.
1694
1702
  */
1695
- delete(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1703
+ delete(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1696
1704
 
1697
1705
  /**
1698
1706
  * Registers a handler for `HEAD` requests to the given path.
@@ -1700,7 +1708,7 @@ export interface HttpRouter {
1700
1708
  * @param handler The event handler to invoke.
1701
1709
  * @param opts Optional handler configuration such as priority and tracking.
1702
1710
  */
1703
- head(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1711
+ head(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1704
1712
 
1705
1713
  /**
1706
1714
  * Registers a handler for `OPTIONS` requests to the given path.
@@ -1708,7 +1716,7 @@ export interface HttpRouter {
1708
1716
  * @param handler The event handler to invoke.
1709
1717
  * @param opts Optional handler configuration such as priority and tracking.
1710
1718
  */
1711
- options(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1719
+ options(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1712
1720
 
1713
1721
  /**
1714
1722
  * Registers a handler for `TRACE` requests to the given path.
@@ -1716,7 +1724,7 @@ export interface HttpRouter {
1716
1724
  * @param handler The event handler to invoke.
1717
1725
  * @param opts Optional handler configuration such as priority and tracking.
1718
1726
  */
1719
- trace(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1727
+ trace(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1720
1728
 
1721
1729
  /**
1722
1730
  * Registers a handler for `QUERY` requests to the given path.
@@ -1724,7 +1732,7 @@ export interface HttpRouter {
1724
1732
  * @param handler The event handler to invoke.
1725
1733
  * @param opts Optional handler configuration such as priority and tracking.
1726
1734
  */
1727
- query(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): void
1735
+ query(path: string, handler: HttpEventHandler, opts?: HttpEventArgs): this
1728
1736
 
1729
1737
  /** Allows registering a handler for any HTTP method, including custom ones.
1730
1738
  * @example