You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-30
Original file line number
Diff line number
Diff line change
@@ -14,12 +14,13 @@
14
14
15
15
Why `fast-maker`?
16
16
17
-
fastify.js already have auto route mechanics using [fastify-autoload](https://github.com/fastify/fastify-autoload). But why you have to use `fast-maker`?
17
+
fastify.js already have excellent auto route mechanics using [fastify-autoload](https://github.com/fastify/fastify-autoload). But why you have to use `fast-maker`?
18
18
19
+
1. Zero cost in Run-Time.
19
20
1.[Static analysis](https://en.wikipedia.org/wiki/Static_program_analysis): `fast-maker` generate TypeScript source code. Because it help to find error in compile-time, not runtime
20
-
2. Complex Variable: You can use like that: `/person/[kind]-[id]/`. It help to get id and kind of id, for example serial-number and id or db-pk and id
21
-
3. Next.js: `fast-maker` use the same mechanics as [Next.js](https://nextjs.org/docs/routing/introduction)
22
-
4.`fast-maker` support a beautiful cli-interface
21
+
1. Flexable Routing: You can use like that: `/person/[kind]-[id]/`. It help to get id and kind of id, for example serial-number and id or db-pk and id, even if you can use regular expression.
22
+
1. Unifying how route paths are built: `fast-maker` use the same mechanics as [Next.js](https://nextjs.org/docs/routing/introduction). Route paths using file-system cannot be developer-specific
23
+
1.`fast-maker` support a beautiful cli-interface
23
24
24
25
## Table of Contents <!-- omit in toc -->
25
26
@@ -88,9 +89,6 @@ npx fast-maker --help
88
89
# display help for route commands
89
90
npx fast-maker route --help
90
91
91
-
# display help for watch commands
92
-
npx fast-maker watch --help
93
-
94
92
# display help for init commands
95
93
npx fast-maker init --help
96
94
```
@@ -107,26 +105,29 @@ use file-system.
107
105
108
106
```text
109
107
handlers/
110
-
├─ get/
111
-
│ ├─ hero/
112
-
│ │ ├─ [name].ts
113
-
├─ post/
114
-
│ ├─ hero.ts
115
-
├─ put/
116
-
│ ├─ hero/
117
-
│ │ ├─ [name].ts
118
-
├─ delete/
119
-
│ ├─ hero/
120
-
│ │ ├─ [name].ts
108
+
├─ superheros/
109
+
│ ├─ [id]/
110
+
│ │ ├─ powers/
111
+
│ │ │ ├─ [id]/
112
+
│ │ │ │ ├─ delete.ts
113
+
│ │ │ │ ├─ get.ts
114
+
│ │ │ │ ├─ put.ts
115
+
│ │ │ ├─ post.ts
116
+
│ │ ├─ delete.ts
117
+
│ │ ├─ get.ts
118
+
│ │ ├─ put.ts
119
+
│ ├─ get.ts
120
+
│ ├─ post.ts
121
121
```
122
122
123
-
`get`, `post`, `put`, `delete`directory represent _HTTP Method_. Also you can use `options`, `patch`, `head`, `all`directory.
123
+
`get`, `post`, `put`, `delete`filename represent _HTTP Method_. Also you can use `options`, `patch`, `head`, `all`filename.
124
124
125
125
### Route options
126
126
127
127
You can pass `RouteShorthandOptions` option like that,
128
128
129
129
```ts
130
+
// When not using a `fastify` instance, you can declare it as a variable like this
@@ -155,26 +172,27 @@ export default async function (
155
172
}
156
173
```
157
174
158
-
You have to `non-named export`(aka default export). Also you can use arrow function and you can use any name under TypeScript function name rule, as well as type arguments perfectly applied on route configuration
175
+
You have to `named export`and variable name must be a `handler`. Also you can use arrow function and you can use any name under TypeScript function name rule, as well as type arguments perfectly applied on route configuration
159
176
160
177
### Variable in Route Path
161
178
162
179
File or Directory name surrounded square bracket like that,
163
180
164
181
```text
165
182
handlers/
166
-
├─ get/
167
-
│ ├─ hero/
168
-
│ │ ├─ [name].ts
183
+
├─ superheros/
184
+
│ ├─ [id]/
185
+
│ │ ├─ get.ts
186
+
│ │ ├─ put.ts
169
187
```
170
188
171
-
Complex variable, No problem.
189
+
Multiple variable, No problem.
172
190
173
191
```text
174
192
handlers/
175
-
├─ get/
176
-
│ ├─ hero/
177
-
│ │ ├─ [affiliation]-[name].ts
193
+
├─ superheros/
194
+
│ ├─ [kind]-[id]/
195
+
│ │ ├─ get.ts
178
196
```
179
197
180
198
This route path access like that: `curl http://localhost:8080/hero/marvel-ironman`
@@ -192,10 +210,10 @@ A complete example of using `fast-maker` can be found at [Ma-eum](https://github
Don't worry about request type arguments, detail type declare and error prevent!
101
103
102
104
## RouteShorthandOptions
103
105
104
-
Named export `option` variable use to RouteShorthandOptions. I recommand using [simple-tjscli](https://www.npmjs.com/package/simple-tjscli). or [crate-ts-json-schema](https://github.com/imjuni/create-ts-json-schema). simple-tjscli, create-ts-json-schema can transfile TypeScript interface to JSONSchema. So you can pass like that.
106
+
Named export `option` variable use to RouteShorthandOptions. I recommand using [simple-tjscli](https://www.npmjs.com/package/simple-tjscli). or [schema-nozzle](https://github.com/imjuni/schema-nozzle). simple-tjscli, schema-nozzle can transfile TypeScript interface to JSONSchema. So you can pass like that.
0 commit comments