next-ssr-middleware 1.0.2 → 1.1.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/ReadMe.md +7 -6
- package/dist/API.d.ts +4 -4
- package/dist/API.js +2 -2
- package/dist/API.js.map +1 -1
- package/package.json +11 -12
- package/source/API.ts +13 -8
package/ReadMe.md
CHANGED
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
## Versions
|
|
11
11
|
|
|
12
|
-
| SemVer
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
| `>=0.
|
|
17
|
-
|
|
|
12
|
+
| SemVer | status | Next.js | MobX | [MobX i18n][6] | Koa |
|
|
13
|
+
| :-----------: | :----------: | :-------: | :---------: | :------------: | :---: |
|
|
14
|
+
| `>=1` | ✅developing | `>=15` | ❌ | ❌ | `>=2` |
|
|
15
|
+
| `>=0.10 <1` | ❌deprecated | `>=15` | `>=6.11` | `>=0.5` | `2.x` |
|
|
16
|
+
| `>=0.9 <0.10` | ✅developing | `>=15` | `>=6.11` | `>=0.5` | ❌ |
|
|
17
|
+
| `>=0.7 <0.9` | ❌deprecated | `>=9 <15` | `>=6.11` | `>=0.5` | ❌ |
|
|
18
|
+
| `<0.7` | ❌deprecated | `>=9 <15` | `>=4 <6.11` | `<0.5` | ❌ |
|
|
18
19
|
|
|
19
20
|
## Middlewares
|
|
20
21
|
|
package/dist/API.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RouterOptions, RouterContext, RouterInstance } from '@koa/router';
|
|
2
2
|
import Koa, { Middleware } from 'koa';
|
|
3
3
|
export type KoaOption = ConstructorParameters<typeof Koa>[0];
|
|
4
4
|
export type KoaCallback = ReturnType<(typeof Koa)['prototype']['callback']>;
|
|
5
5
|
export declare function withKoa<S, C>(...middlewares: Middleware<S, C>[]): KoaCallback;
|
|
6
6
|
export declare function withKoa<S, C>(option: KoaOption, ...middlewares: Middleware<S, C>[]): KoaCallback;
|
|
7
7
|
export declare const pageApiRouteOf: (path: string) => string;
|
|
8
|
-
export declare const createKoaRouter: <S, C extends
|
|
9
|
-
export declare function withKoaRouter<S, C extends
|
|
10
|
-
export declare function withKoaRouter<S, C extends
|
|
8
|
+
export declare const createKoaRouter: <S, C extends RouterContext<S>>(moduleURI: string, option?: RouterOptions) => RouterInstance<S, C>;
|
|
9
|
+
export declare function withKoaRouter<S, C extends RouterContext<S>>(router: RouterInstance<S, C>, ...middlewares: Middleware<S, C>[]): KoaCallback;
|
|
10
|
+
export declare function withKoaRouter<S, C extends RouterContext<S>>(option: KoaOption, router: RouterInstance<S, C>, ...middlewares: Middleware<S, C>[]): KoaCallback;
|
package/dist/API.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.withKoa = withKoa;
|
|
|
5
5
|
exports.withKoaRouter = withKoaRouter;
|
|
6
6
|
var tslib_1 = require("tslib");
|
|
7
7
|
var bodyparser_1 = tslib_1.__importDefault(require("@koa/bodyparser"));
|
|
8
|
-
var router_1 =
|
|
8
|
+
var router_1 = require("@koa/router");
|
|
9
9
|
var koa_1 = tslib_1.__importDefault(require("koa"));
|
|
10
10
|
function withKoa() {
|
|
11
11
|
var _a, e_1, _b;
|
|
@@ -43,7 +43,7 @@ var pageApiRouteOf = function (path) {
|
|
|
43
43
|
.match(/pages(\/api\/.+)\.(j|t)s/)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.split('/[')[0]) === null || _c === void 0 ? void 0 : _c.replace(/\/index$/, '');
|
|
44
44
|
};
|
|
45
45
|
exports.pageApiRouteOf = pageApiRouteOf;
|
|
46
|
-
var createKoaRouter = function (moduleURI, option) { return new router_1.
|
|
46
|
+
var createKoaRouter = function (moduleURI, option) { return new router_1.Router(tslib_1.__assign(tslib_1.__assign({}, option), { prefix: (0, exports.pageApiRouteOf)(moduleURI) })); };
|
|
47
47
|
exports.createKoaRouter = createKoaRouter;
|
|
48
48
|
function withKoaRouter() {
|
|
49
49
|
var _a, _b;
|
package/dist/API.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../source/API.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"API.js","sourceRoot":"","sources":["../source/API.ts"],"names":[],"mappings":";;;AAkBA,0BAcC;AAsBD,sCAiBC;;AAvED,uEAAyC;AACzC,sCAKqB;AACrB,oDAAsC;AAWtC,SAAgB,OAAO;;IAAO,oBAAoB;SAApB,UAAoB,EAApB,qBAAoB,EAApB,IAAoB;QAApB,+BAAoB;;IAC9C,IAAI,MAA6B,CAAC;IAClC,IAAI,WAAW,GAAuB,EAAE,CAAC;IAEzC,IAAI,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;QACtC,MAAM,GAAG,SAAS,CAAC;QACnB,WAAW,GAAG,UAAU,CAAC;IAC7B,CAAC;;QAAM,KAAA,eAA2B,UAAU,CAAA,EAApC,MAAM,QAAA,EAAK,WAAW,cAAA,CAAe;IAE7C,IAAM,GAAG,GAAG,IAAI,aAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAA,oBAAU,GAAE,CAAC,CAAC;;QAE9C,KAAyB,IAAA,gBAAA,iBAAA,WAAW,CAAA,wCAAA;YAA/B,IAAM,UAAU,wBAAA;YAAiB,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SAAA;;;;;;;;;IAE1D,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAEM,IAAM,cAAc,GAAG,UAAC,IAAY;;IACvC,OAAA,MAAA,MAAA,MAAA,SAAS,CAAC,IAAI,CAAC;SACV,KAAK,CAAC,0BAA0B,CAAC,0CAAG,CAAC,CAAC,0CACrC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,0CACd,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;CAAA,CAAC;AAJrB,QAAA,cAAc,kBAIO;AAE3B,IAAM,eAAe,GAAG,UAC3B,SAAiB,EACjB,MAAsB,IACrB,OAAA,IAAI,eAAM,uCAAY,MAAM,KAAE,MAAM,EAAE,IAAA,sBAAc,EAAC,SAAS,CAAC,IAAG,EAAlE,CAAkE,CAAC;AAH3D,QAAA,eAAe,mBAG4C;AAWxE,SAAgB,aAAa;;IACzB,oBAAoB;SAApB,UAAoB,EAApB,qBAAoB,EAApB,IAAoB;QAApB,+BAAoB;;IAEpB,IAAI,MAA6B,CAAC;IAClC,IAAI,MAA4B,CAAC;IACjC,IAAI,WAAW,GAAuB,EAAE,CAAC;IAEzC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU;QACrD,KAAA,eAA2B,UAAU,CAAA,EAApC,MAAM,QAAA,EAAK,WAAW,cAAA,CAAe;;QACrC,KAAA,eAAmC,UAAU,CAAA,EAA5C,MAAM,QAAA,EAAE,MAAM,QAAA,EAAK,WAAW,cAAA,CAAe;IAEnD,OAAO,OAAO,sCACV,MAAM;QACN,MAAM,CAAC,MAAM,EAAE;QACf,MAAM,CAAC,cAAc,EAAE,kBACpB,WAAW,WAChB;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-ssr-middleware",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"author": "shiy2008@gmail.com",
|
|
6
6
|
"description": "Koa-like middlewares for Next.js Back-end API & Server Side Rendering",
|
|
@@ -23,30 +23,29 @@
|
|
|
23
23
|
"main": "dist/index.js",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@koa/bodyparser": ">=5",
|
|
26
|
-
"@koa/router": "
|
|
26
|
+
"@koa/router": ">=13",
|
|
27
27
|
"@types/jsonwebtoken": "^9.0.10",
|
|
28
28
|
"@types/koa": ">=2",
|
|
29
|
-
"@types/
|
|
30
|
-
"
|
|
31
|
-
"jsonwebtoken": "^9.0.2",
|
|
29
|
+
"@types/react": "^19.2.7",
|
|
30
|
+
"jsonwebtoken": "^9.0.3",
|
|
32
31
|
"koa": ">=2",
|
|
33
32
|
"tslib": "^2.8.1",
|
|
34
|
-
"web-utility": "^4.4
|
|
33
|
+
"web-utility": "^4.6.4"
|
|
35
34
|
},
|
|
36
35
|
"peerDependencies": {
|
|
37
36
|
"next": ">=9.3",
|
|
38
37
|
"react": ">=18"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@types/node": "^22.
|
|
40
|
+
"@types/node": "^22.19.3",
|
|
42
41
|
"husky": "^9.1.7",
|
|
43
42
|
"koajax": "^3.1.2",
|
|
44
|
-
"lint-staged": "^16.
|
|
45
|
-
"next": "^
|
|
43
|
+
"lint-staged": "^16.2.7",
|
|
44
|
+
"next": "^16.0.10",
|
|
46
45
|
"open-cli": "^8.0.0",
|
|
47
|
-
"prettier": "^3.
|
|
48
|
-
"typedoc": "^0.28.
|
|
49
|
-
"typescript": "~5.9.
|
|
46
|
+
"prettier": "^3.7.4",
|
|
47
|
+
"typedoc": "^0.28.15",
|
|
48
|
+
"typescript": "~5.9.3"
|
|
50
49
|
},
|
|
51
50
|
"pnpm": {
|
|
52
51
|
"onlyBuiltDependencies": [
|
package/source/API.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import BodyParser from '@koa/bodyparser';
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
Router,
|
|
4
|
+
RouterOptions,
|
|
5
|
+
RouterContext,
|
|
6
|
+
RouterInstance
|
|
7
|
+
} from '@koa/router';
|
|
3
8
|
import Koa, { Middleware } from 'koa';
|
|
4
9
|
|
|
5
10
|
export type KoaOption = ConstructorParameters<typeof Koa>[0];
|
|
@@ -33,25 +38,25 @@ export const pageApiRouteOf = (path: string) =>
|
|
|
33
38
|
?.split('/[')[0]
|
|
34
39
|
?.replace(/\/index$/, '');
|
|
35
40
|
|
|
36
|
-
export const createKoaRouter = <S, C extends
|
|
41
|
+
export const createKoaRouter = <S, C extends RouterContext<S>>(
|
|
37
42
|
moduleURI: string,
|
|
38
43
|
option?: RouterOptions
|
|
39
44
|
) => new Router<S, C>({ ...option, prefix: pageApiRouteOf(moduleURI) });
|
|
40
45
|
|
|
41
|
-
export function withKoaRouter<S, C extends
|
|
42
|
-
router:
|
|
46
|
+
export function withKoaRouter<S, C extends RouterContext<S>>(
|
|
47
|
+
router: RouterInstance<S, C>,
|
|
43
48
|
...middlewares: Middleware<S, C>[]
|
|
44
49
|
): KoaCallback;
|
|
45
|
-
export function withKoaRouter<S, C extends
|
|
50
|
+
export function withKoaRouter<S, C extends RouterContext<S>>(
|
|
46
51
|
option: KoaOption,
|
|
47
|
-
router:
|
|
52
|
+
router: RouterInstance<S, C>,
|
|
48
53
|
...middlewares: Middleware<S, C>[]
|
|
49
54
|
): KoaCallback;
|
|
50
|
-
export function withKoaRouter<S, C extends
|
|
55
|
+
export function withKoaRouter<S, C extends RouterContext<S>>(
|
|
51
56
|
...parameters: any[]
|
|
52
57
|
) {
|
|
53
58
|
let option: KoaOption | undefined;
|
|
54
|
-
let router:
|
|
59
|
+
let router: RouterInstance<S, C>;
|
|
55
60
|
let middlewares: Middleware<S, C>[] = [];
|
|
56
61
|
|
|
57
62
|
if (!parameters[1] || typeof parameters[1] === 'function')
|