@evjs/create-app 0.3.12 → 0.3.13
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/package.json +1 -1
- package/templates/api-routes/README.md +4 -2
- package/templates/api-routes/package.json +1 -1
- package/templates/api-routes/src/middlewares/middleware.ts +7 -0
- package/templates/api-routes/src/{middleware.ts → middlewares/response-metadata.ts} +2 -2
- package/templates/basic/package.json +1 -1
- package/templates/complex-routing/package.json +1 -1
- package/templates/custom-ws-transport/package.json +1 -1
- package/templates/mpa/package.json +1 -1
- package/templates/plugin-authoring/package.json +1 -1
- package/templates/with-sqlite/package.json +1 -1
- package/templates/with-tailwind/package.json +1 -1
- package/templates/with-trpc/package.json +1 -1
package/package.json
CHANGED
|
@@ -15,7 +15,8 @@ npm run dev
|
|
|
15
15
|
| `ev.config.ts` | Selects SPA routing mode |
|
|
16
16
|
| `src/pages/page.tsx` | Root Page that exercises the REST endpoints |
|
|
17
17
|
| `src/pages/layout.tsx` | File-convention root layout |
|
|
18
|
-
| `src/middleware.ts` |
|
|
18
|
+
| `src/middlewares/middleware.ts` | Ordered global middleware composition anchor |
|
|
19
|
+
| `src/middlewares/response-metadata.ts` | Ordinary middleware module composed by the anchor |
|
|
19
20
|
| `src/apis/api/middleware.ts` | API route middleware for `/api/**` file routes |
|
|
20
21
|
| `src/apis/api/posts/api.ts` | List/create handlers for `/api/posts` |
|
|
21
22
|
| `src/apis/api/posts/$id/api.ts` | Dynamic handlers for `/api/posts/:id` |
|
|
@@ -29,7 +30,8 @@ npm run dev
|
|
|
29
30
|
- Query string parsing (`?limit=N`)
|
|
30
31
|
- Custom status codes (201, 204, 404)
|
|
31
32
|
- Auto `OPTIONS` and `405 Method Not Allowed`
|
|
32
|
-
-
|
|
33
|
+
- Explicitly ordered global middleware composition with `MiddlewareChain`
|
|
34
|
+
- Route-scoped API `middleware.ts` conventions
|
|
33
35
|
- Colocated private helpers that are not named `api.ts`
|
|
34
36
|
- A root `page.tsx` anchor mapped to `/` by file convention
|
|
35
37
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from "@evjs/ev/server-context";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const responseMetadata: MiddlewareHandler = async (ctx, next) => {
|
|
4
4
|
const startedAt = Date.now();
|
|
5
5
|
await next();
|
|
6
6
|
ctx.header("x-example-server", "api-routes");
|
|
7
7
|
ctx.header("x-response-time-ms", String(Date.now() - startedAt));
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export default
|
|
10
|
+
export default responseMetadata;
|