galbe 0.6.0 → 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.
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: '[bug] '
5
+ labels: bug
6
+ assignees: ''
7
+ ---
8
+
9
+ **Describe the bug**
10
+
11
+ <!-- A clear and concise description of what the bug is. -->
12
+
13
+ **Steps To Reproduce**
14
+
15
+ <!-- Steps to reproduce the behavior -->
16
+
17
+ **Expected behavior**
18
+
19
+ <!-- A clear and concise description of what you expected to happen. -->
20
+
21
+ **Screenshots**
22
+
23
+ <!-- If applicable, add screenshots to help explain your problem. -->
24
+
25
+ **Environment (please complete the following information):**
26
+
27
+ <!-- To help us diagnose the issue, please navigate to the root of your project in your terminal and execute "bunx galbe info". Then paste the output bellow -->
28
+
29
+ ```txt
30
+
31
+ ```
32
+
33
+ **Additional context**
34
+
35
+ <!-- Add any other context about the problem here. -->
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: '[feat] '
5
+ labels: enhancement
6
+ assignees: ''
7
+ ---
8
+
9
+ **Is your feature request related to a problem? Please describe.**
10
+
11
+ <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
12
+
13
+ **Describe the solution you'd like**
14
+
15
+ <!-- A clear and concise description of what you want to happen. -->
16
+
17
+ **Describe alternatives you've considered**
18
+
19
+ <!-- A clear and concise description of any alternative solutions or features you've considered. -->
20
+
21
+ **Additional context**
22
+
23
+ <!-- Add any other context or screenshots about the feature request here. -->
@@ -16,5 +16,5 @@ jobs:
16
16
  -H "Accept: application/vnd.github+json" \
17
17
  -H "Authorization: Bearer ${{ secrets.GH_WEBSITE_TOKEN }}" \
18
18
  -H "X-GitHub-Api-Version: 2022-11-28" \
19
- https://api.github.com/repos/pierre-cm/galbe-website/actions/workflows/deploy.yml/dispatches \
19
+ https://api.github.com/repos/pierre-cm/galbe-website/actions/workflows/static.yml/dispatches \
20
20
  -d '{"ref":"main"}'
package/README.md CHANGED
@@ -25,3 +25,5 @@ bun install && bun dev
25
25
  The detailed documentation is available at [galbe.dev](https://galbe.dev).
26
26
 
27
27
  ## Contributing
28
+
29
+ Please refer to the [Contributing Guide](https://github.com/pierre-cm/galbe/blob/main/docs/CONTRIBUTING.md) to start contributing to Galbe.
package/bin/cli.ts CHANGED
@@ -7,11 +7,13 @@ import { pckg } from './util'
7
7
  import dev from './commands/dev'
8
8
  import build from './commands/build'
9
9
  import generate from './commands/generate'
10
+ import info from './commands/info'
10
11
 
11
12
  program.name('galbe').description(pckg.description).version(pckg.version)
12
13
 
13
14
  dev(program.command('dev'))
14
15
  build(program.command('build'))
15
16
  generate(program.command('generate'))
17
+ info(program.command('info'))
16
18
 
17
19
  program.parse()
@@ -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
 
@@ -0,0 +1,29 @@
1
+ import os from 'os'
2
+ import { Command } from 'commander'
3
+
4
+ export default async (cmd: Command) => {
5
+ cmd.description('print informations about the current os, bun and galbe version').action(async () => {
6
+ const osName = os.type()
7
+ const osArch = os.arch()
8
+ const osVersion = os.release()
9
+
10
+ const bunVersion = Bun.version
11
+ const bunRevision = Bun.revision
12
+
13
+ let localPckg: any = {}
14
+ try {
15
+ localPckg = await Bun.file('./node_modules/galbe/package.json').json()
16
+ } catch (err) {}
17
+ const galbeVersion = localPckg?.version || 'not found'
18
+
19
+ console.log('OS')
20
+ console.log(` name: ${osName}`)
21
+ console.log(` arch: ${osArch}`)
22
+ console.log(` version: ${osVersion}`)
23
+ console.log('Bun')
24
+ console.log(` version: ${bunVersion}`)
25
+ console.log(` revision: ${bunRevision}`)
26
+ console.log('Galbe')
27
+ console.log(` version: ${galbeVersion}`)
28
+ })
29
+ }
@@ -0,0 +1,105 @@
1
+ # Contributing to Galbe
2
+
3
+ First off, thank you for considering contributing to our project! We appreciate your time and effort and want to make this as easy and transparent as possible for everyone.
4
+
5
+ ## Create an Issue
6
+
7
+ If you encounter a bug, want to propose a new feature, or something that could be improved, please create an issue. Here's how:
8
+
9
+ 1. **Check Existing Issues**: Before creating a new issue, please search the [existing issues](https://github.com/pierre-cm/galbe/issues) to see if someone else has already reported the same problem or suggested the same feature.
10
+
11
+ 2. **Open a New Issue**: If your issue is new, [open a new issue](https://github.com/pierre-cm/galbe/issues/new/choose) and provide the following details:
12
+
13
+ - **Title**: A concise summary of the issue.
14
+ - **Description**: A detailed description of the problem or suggestion. Include steps to reproduce the issue if applicable.
15
+ - **Screenshots**: If possible, include screenshots or other visual aids that help explain the issue.
16
+ - **Environment**: Mention the environment in which you encountered the issue (e.g., OS, Bun version).
17
+ - **Labels**: Assign appropriate labels (e.g., bug, enhancement) to help categorize your issue.
18
+
19
+ 3. **Follow Up**: Once your issue is submitted, be ready to provide additional information if requested. We'll do our best to address the issue promptly.
20
+
21
+ ## Create a Pull Request
22
+
23
+ ### 1. Fork the Repository
24
+
25
+ If you haven't already, [fork Galbe's repository on GitHub](https://github.com/pierre-cm/galbe/fork). This will create a copy of this repository under your GitHub account.
26
+
27
+ ### 2. Clone Your Fork
28
+
29
+ Clone the forked repository to your local machine:
30
+
31
+ ```bash
32
+ git clone https://github.com/<your-username>/galbe.git
33
+ cd galbe
34
+ ```
35
+
36
+ ### 3. Create a New Branch
37
+
38
+ Before making any changes, create a new branch for your work. Branches help keep your changes separate from the main branch and make it easier to review and merge:
39
+
40
+ ```bash
41
+ git checkout -b feature/your-feature-name
42
+ ```
43
+
44
+ Use a descriptive name for your branch to indicate what you are working on.
45
+
46
+ ### 4. Make Your Changes
47
+
48
+ Make the necessary changes in your branch. Be sure to follow the project's coding style and best practices.
49
+
50
+ ### 5. Commit Your Changes
51
+
52
+ Once you’ve made your changes, commit them with a clear and descriptive message:
53
+
54
+ ```bash
55
+ git add .
56
+ git commit -m "Add feature X to do Y"
57
+ ```
58
+
59
+ ### 6. Push to Your Fork
60
+
61
+ Push your changes to your forked repository on GitHub:
62
+
63
+ ```bash
64
+ git push origin feature/your-feature-name
65
+ ```
66
+
67
+ ### 7. Create a Pull Request
68
+
69
+ Once your changes are pushed to GitHub, you can create a pull request. Go to the [original repository](https://github.com/pierre-cm/galbe) on GitHub, and you should see an option to create a pull request from your branch.
70
+
71
+ - Make sure to provide a detailed description of your changes and why they are necessary.
72
+ - Link any related issues if applicable.
73
+ - If your pull request is still a work in progress, mark it as a draft to let others know that you are not yet ready for a review.
74
+
75
+ ### 8. Respond to Feedback
76
+
77
+ Once your pull request is submitted, it will be reviewed by the project maintainers. They may ask for changes or provide feedback. Please be responsive and make the necessary adjustments.
78
+
79
+ ### Coding Standards
80
+
81
+ Please follow these coding standards to ensure consistency across the project:
82
+
83
+ - **Code Style**: Follow the [style guide]().
84
+ - **Commit Messages**: Use clear and descriptive commit messages.
85
+ - **Documentation**: Update documentation where applicable. This includes comments in the code and other documentation files under the `docs` directory.
86
+
87
+ ## Code of Conduct
88
+
89
+ We are committed to creating a welcoming and inclusive environment for everyone. To ensure this, all contributors are expected to adhere to the following guidelines:
90
+
91
+ 1. **Be Respectful**: Treat everyone with respect. Disagreements are inevitable, but it's important to remain courteous and constructive. Personal attacks, harassment, or offensive comments will not be tolerated.
92
+
93
+ 2. **Collaborate Openly**: Collaboration is key to the success of the project. Be open to feedback and suggestions from others. Constructive criticism should be welcomed and given in a positive manner.
94
+
95
+ 3. **Resolve Disagreements Constructively**: If you find yourself in a disagreement, seek to resolve it in a way that is constructive and respectful. If necessary, involve a project maintainer to help mediate.
96
+
97
+ 4. **Report Issues**: If you witness or experience any behavior that violates this Code of Conduct, please report it immediately to the project maintainers. We take all reports seriously and will address them promptly.
98
+
99
+ By participating in this project, you agree to abide by this Code of Conduct.
100
+
101
+ ## Getting Help
102
+
103
+ If you have any questions or need help, feel free to open an issue or contact one of the maintainers.
104
+
105
+ Thank you for your contribution!
package/docs/cli.md CHANGED
@@ -12,7 +12,7 @@ Install it globally using the following command:
12
12
  $ bun install -g galbe
13
13
  ```
14
14
 
15
- Run it with `bunx`:
15
+ Or run it with `bunx`:
16
16
 
17
17
  ```bash
18
18
  $ bunx galbe
@@ -38,16 +38,19 @@ Start a dev server running your Galbe application.
38
38
 
39
39
  #### Example
40
40
 
41
- ```js
42
- // index.js
41
+ index.js
43
42
 
43
+ ```js
44
44
  import { Galbe } from 'galbe'
45
45
 
46
- export default new Galbe()
46
+ const g = new Galbe()
47
+ g.get('example', () => '')
48
+
49
+ export default g
47
50
  ```
48
51
 
49
52
  ```bash
50
- $ galbe dev index.js -p 7357 --watch
53
+ $ galbe dev index.js -p 7357 -w
51
54
  ```
52
55
 
53
56
  ## build
@@ -66,13 +69,13 @@ Bundle your Galbe application.
66
69
  | ----- | --------- | ------------------------------ | -------- |
67
70
  | -o | --out | output directory | dist/app |
68
71
  | -C | --compile | create a standalone executable | false |
69
- | -c | --config | bun config (js or ts) | - |
72
+ | -c | --config | bun config (js or ts) | |
70
73
 
71
74
  #### Example
72
75
 
73
- ```js
74
- // index.js
76
+ index.js
75
77
 
78
+ ```js
76
79
  import { Galbe } from 'galbe'
77
80
 
78
81
  export default new Galbe()
@@ -105,10 +108,10 @@ Generate a client for your Galbe application.
105
108
 
106
109
  #### Examples
107
110
 
108
- Let's setup a new Galbe project:
111
+ Let's first setup a new Galbe project:
109
112
 
110
113
  ```bash
111
- $ bun create galbe galbe-example -t hello -l ts
114
+ $ bun create galbe galbe-example --template hello --lang ts
112
115
  $ cd galbe-example
113
116
  $ bun install
114
117
  ```
@@ -128,9 +131,9 @@ $ galbe generate client index.ts
128
131
  This will generate a `dist/client.ts` client lib by default.
129
132
  You can import it and use it like in the following example:
130
133
 
131
- ```ts
132
- // client_example.ts
134
+ client_example.ts
133
135
 
136
+ ```ts
134
137
  import HelloClient from './dist/client'
135
138
 
136
139
  const client = new HelloClient({ server: { url: 'http://localhost:3000' } })
@@ -191,8 +194,9 @@ $ ./dist/cli hello Pierre -a 29
191
194
  Hello Pierre! You're 29 y.o.
192
195
  ```
193
196
 
194
- > [!NOTE]
195
- > In order to be able to fetch the correct server url, the cli requires to set an env variable `GCLI_SERVER_URL` with the url of your Galbe app.
197
+ > [!IMPORTANT]
198
+ > A `GCLI_SERVER_URL` environment variable must be defined. It should indicates the url of the Galbe server you want to target.
199
+ > In that specific case `http://localhost:3000`.
196
200
 
197
201
  ### spec
198
202
 
@@ -209,7 +213,7 @@ Generate the spec of your Galbe application.
209
213
  | Short | Long | Descritpion | Default |
210
214
  | ----- | -------- | ------------------------------------------------ | ----------------------- |
211
215
  | -t | --target | spec target [openapi:3.0:json, openapi:3.0:yaml] | openapi:3.0:yaml |
212
- | -b | --base | base spec file | - |
216
+ | -b | --base | base spec file | |
213
217
  | -o | --out | output file | spec/api.(yaml \| json) |
214
218
 
215
219
  #### Example
@@ -302,7 +306,7 @@ This should generate the code of our application in the `src` directory by defau
302
306
  To test that the code was successfully generated, you can run:
303
307
 
304
308
  ```bash
305
- $ bunx galbe dev index.ts
309
+ $ galbe dev index.ts
306
310
  🏗️ Constructing routes
307
311
 
308
312
  src/routes/pet.route.ts
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.0",
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",