galbe 0.6.1 → 0.6.2

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.
@@ -280,6 +280,7 @@ const parseEndpointDef = (method: string, path: string, def?: OpenAPIV3.Operatio
280
280
  let rs = Object.fromEntries(
281
281
  Object.entries(r || {}).map(([status, sv]) => {
282
282
  let entries: string[] = []
283
+ let s: string = Number.isInteger(Number(status)) ? status : '200'
283
284
  for (let [_type, tv] of Object.entries((sv as OpenAPIV3.ResponseObject)?.content || {})) {
284
285
  entries.push(
285
286
  unref(parseOapiSchema(tv.schema), m => {
@@ -289,7 +290,7 @@ const parseEndpointDef = (method: string, path: string, def?: OpenAPIV3.Operatio
289
290
  })
290
291
  )
291
292
  }
292
- return [status, [...new Set(entries)]]
293
+ return [s, [...new Set(entries)]]
293
294
  })
294
295
  )
295
296
 
package/docs/cli.md CHANGED
@@ -111,7 +111,7 @@ Generate a client for your Galbe application.
111
111
  Let's first setup a new Galbe project:
112
112
 
113
113
  ```bash
114
- $ bun create galbe galbe-example -t hello -l ts
114
+ $ bun create galbe galbe-example --template hello --lang ts
115
115
  $ cd galbe-example
116
116
  $ bun install
117
117
  ```
package/docs/plugins.md CHANGED
@@ -4,6 +4,8 @@ Galbe provides a powerful plugin system that allows developers to extend and cus
4
4
 
5
5
  ## Definition
6
6
 
7
+ ### Signature
8
+
7
9
  ```ts
8
10
  type GalbePlugin = {
9
11
  name: string
@@ -47,7 +49,7 @@ This method is called after the route handler has been called and before the res
47
49
 
48
50
  It is preemptable, meaning that any returned value will be interpreted as a response to send back to the client. Therefore, the method should only return [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) instances or nothing.
49
51
 
50
- ## Registration
52
+ ### Usage
51
53
 
52
54
  To register a plugin with your Galbe server, you must use the `use` method from you galbe instance.
53
55
 
@@ -56,7 +58,21 @@ const galbe = new Galbe()
56
58
  galbe.use(plugin)
57
59
  ```
58
60
 
59
- ## Example
61
+ ## Create a plugin
62
+
63
+ ### 1. Scaffolding
64
+
65
+ The Galbe starter CLI provides a template that can be used to setup a Galbe plugin project.
66
+
67
+ ```bash
68
+ $ bun create galbe my-plugin --template plugin
69
+ $ cd my-plugin
70
+ $ bun install
71
+ ```
72
+
73
+ Now you should be ready to start developing your plugin. Following section will present an example of a plugin implementation.
74
+
75
+ ### 2. Implementation
60
76
 
61
77
  Here is an example of a plugin implementation that handles routes tagged with `@deprecated` metadata (See [Route files](routes.md#route-files) section about metadata).
62
78
 
@@ -100,8 +116,6 @@ export default () => {
100
116
  }
101
117
  ```
102
118
 
103
- index.ts
104
-
105
119
  ```ts
106
120
  import { Galbe } from 'galbe'
107
121
  import deprecatedPlugin from './deprecated.plugin'
@@ -111,3 +125,29 @@ galbe.use(deprecatedPlugin())
111
125
 
112
126
  export default galbe
113
127
  ```
128
+
129
+ ### 3. Publishing
130
+
131
+ If you want to submit your plugin to the [official plugin list](https://galbe.dev/plugins), you should follow these steps:
132
+
133
+ 1. Create a **public** Github repository for your plugin. Make sure to include the following information in the README at the root of your repository:
134
+
135
+ - A description of your plugin and what it does.
136
+ - How to install and configure it.
137
+ - How to use it.
138
+
139
+ 2. (_Optional_) Publish your plugin to [NPM](https://npmjs.com).
140
+
141
+ 3. Create a Pull Request adding your plugin config to [plugins.json](https://github.com/pierre-cm/galbe-website/blob/main/plugins.json) file. The config should be in the following format:
142
+
143
+ ```json
144
+ "plugin-id": {
145
+ "name": "Plugin Name",
146
+ "description": "Plugin description",
147
+ "repo": "https://github.com/<username>/<repo-name>",
148
+ "npm": "https://www.npmjs.com/package/<package-name>",
149
+ }
150
+ ```
151
+
152
+ > [!IMPORTANT]
153
+ > Please provide any relevent information about the plugin in the Pull Request description. It will be reviewed by the project maintainers as soon as possible. Be sure to check the [Glabe Contributing Guide](https://github.com/pierre-cm/galbe/blob/main/docs/CONTRIBUTING.md) before submitting any request. Same rules will apply here.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "galbe",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Fast, lightweight and highly customizable JavaScript web framework based on Bun",
5
5
  "author": "Pierre Caillaud M (https://github.com/pierre-cm)",
6
6
  "type": "module",