@bepalo/spine 1.5.16 → 1.5.17
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 +1 -80
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ Average 10.05k 8.13k 7.65k ┌────────
|
|
|
73
73
|
- 🧠 **TypeScript-first** — extend the request context with your own application data
|
|
74
74
|
- 🌐 **Runtime agnostic** — works with Bun, Deno, Node.js, and other Web API-compatible runtimes
|
|
75
75
|
- 📁 **File-based routing** — optionally load routes directly from a directory structure
|
|
76
|
-
- 📖
|
|
76
|
+
- 📖 OpenAPI 3.0 generation — route metadata, tags, parameters, schemas, security, components, and configurable sorting
|
|
77
77
|
- 🛠️ **Built-in utilities** — request parsing, responses, CORS, rate limiting, and authentication
|
|
78
78
|
- 🪶 **No server lock-in** — Spine only deals with `Request` in and `Response` out
|
|
79
79
|
|
|
@@ -106,85 +106,6 @@ Average 10.05k 8.13k 7.65k ┌────────
|
|
|
106
106
|
- [Thanks and Enjoy](#️-thanks-and-enjoy)
|
|
107
107
|
- [Be a Sponsor](#-be-a-sponsor)
|
|
108
108
|
|
|
109
|
-
## What is new v1.2.10?
|
|
110
|
-
|
|
111
|
-
- Implemented static route generator function `generateStaticRoutesImporter` to use with nextjs, cloudflare workers and more which do not do accept dynamic imports.
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
// src/server/utils/gen-routes.ts
|
|
115
|
-
import Router from "@bepalo/spine";
|
|
116
|
-
import generateStaticRoutesImporter from "@bepalo/spine";
|
|
117
|
-
|
|
118
|
-
await generateStaticRoutesImporter(
|
|
119
|
-
new Router(),
|
|
120
|
-
"./src/server/routes",
|
|
121
|
-
"./routes/",
|
|
122
|
-
).then((content) =>
|
|
123
|
-
Bun.write("./src/server/index.ts", "// src/server/index.ts\n" + content),
|
|
124
|
-
);
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
```ts
|
|
128
|
-
// src/server/index.ts
|
|
129
|
-
// This is auto-generated for static importing of @bepalo/spine file-based routes
|
|
130
|
-
import {
|
|
131
|
-
Router,
|
|
132
|
-
Handler,
|
|
133
|
-
HandlerRegisterPiplineOptions,
|
|
134
|
-
Pipeline,
|
|
135
|
-
} from "@bepalo/spine";
|
|
136
|
-
import * as route__index from "./routes/_index";
|
|
137
|
-
import * as route_api_$$$path from "./routes/api/[## path]";
|
|
138
|
-
import * as route_api_$ from "./routes/api/[[#]]";
|
|
139
|
-
import * as route_api_fruits from "./routes/api/fruits";
|
|
140
|
-
import * as route_api_users_$$$usersPath from "./routes/api/users/[## usersPath]";
|
|
141
|
-
import * as route_api_users_$$$id from "./routes/api/users/[id]";
|
|
142
|
-
import * as route_pages_$$ from "./routes/pages/[[##]]";
|
|
143
|
-
|
|
144
|
-
const getOptions = <ExtendContext extends Record<string, unknown>>(
|
|
145
|
-
def: {
|
|
146
|
-
pipe: Handler<ExtendContext> | Pipeline<ExtendContext>;
|
|
147
|
-
} & HandlerRegisterPiplineOptions,
|
|
148
|
-
) => {
|
|
149
|
-
const { pipe, ...options } = def;
|
|
150
|
-
return options;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export const setRoutes = async <ExtendContext extends Record<string, unknown>>(
|
|
154
|
-
router: Router<ExtendContext>,
|
|
155
|
-
) => {
|
|
156
|
-
// /
|
|
157
|
-
router.handleGet(
|
|
158
|
-
"/_index",
|
|
159
|
-
route__index.Get.pipe,
|
|
160
|
-
getOptions(route__index.Get),
|
|
161
|
-
);
|
|
162
|
-
router.filterGet("/_index", route__index.Get_Filter);
|
|
163
|
-
// /api
|
|
164
|
-
router.filterGet("/api/::path", route_api_$$$path.Get_Filter);
|
|
165
|
-
router.filterGet("/api/*!", route_api_$.Get_Filter);
|
|
166
|
-
router.handleDelete("/api/fruits", route_api_fruits.Delete);
|
|
167
|
-
router.handleGet("/api/fruits", route_api_fruits.Get);
|
|
168
|
-
router.handlePatch("/api/fruits", route_api_fruits.Patch);
|
|
169
|
-
router.handlePost("/api/fruits", route_api_fruits.Post);
|
|
170
|
-
// /api/users
|
|
171
|
-
router.filterGet(
|
|
172
|
-
"/api/users/::usersPath",
|
|
173
|
-
route_api_users_$$$usersPath.Get_Filter,
|
|
174
|
-
);
|
|
175
|
-
router.handleGet(
|
|
176
|
-
"/api/users/:id",
|
|
177
|
-
route_api_users_$$$id.Get.pipe,
|
|
178
|
-
getOptions(route_api_users_$$$id.Get),
|
|
179
|
-
);
|
|
180
|
-
// /pages
|
|
181
|
-
router.handleGet("/pages/**!", route_pages_$$.Get);
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// Use this to set the routes in your router
|
|
185
|
-
export default setRoutes;
|
|
186
|
-
```
|
|
187
|
-
|
|
188
109
|
## Quick Start
|
|
189
110
|
|
|
190
111
|
Install
|