Skip to content

Commit

Permalink
Add: actions pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
NobleMajo committed Jan 18, 2025
1 parent 6c2863c commit 73a6110
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 63 deletions.
21 changes: 21 additions & 0 deletions .github/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { BuildConfig } from 'bun'
import dts from 'bun-plugin-dts'

const defaultBuildConfig: BuildConfig = {
entrypoints: ['./src/index.ts'],
outdir: './dist'
}

await Promise.all([
Bun.build({
...defaultBuildConfig,
plugins: [dts()],
format: 'esm',
naming: "[dir]/[name].js",
}),
Bun.build({
...defaultBuildConfig,
format: 'cjs',
naming: "[dir]/[name].cjs",
})
])
67 changes: 67 additions & 0 deletions .github/workflows/auto-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: auto-update
run-name: Update npm dependencies

on:
schedule:
- cron: '30 12 4,18 * *'
workflow_dispatch:

permissions:
contents: write

jobs:
update-deps:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Bun.js
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Update bun dependencies
run: |
bun bump
bun update
bun run build
bun test --if-present
- name: Commit and push changes
uses: EndBug/add-and-commit@v9
with:
add: 'package*.json'
message: 'Bot: bun deps update'

- name: Store build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist
package*.json
publish-npm:
needs: update-deps
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Bun.js
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: dist

- name: Publish to npmjs.com
run: bun publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/first-interaction-greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: first-interaction-greetings
run-name: First interaction greetings

on: [pull_request_target, issues]

jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: First interaction greetings
uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: |
👋 Hii!
Welcome to the repository, and thank you for opening an issue. 🎉
We're excited to have you contribute!
Please make sure to include all the relevant details to help us understand your report or suggestion.
If you’re new here, take a moment to review our [contribution guidelines](../blob/main/CONTRIBUTING.md).
These document will help you collaborate effectively and ensure a positive experience for everyone.
We appreciate your effort and look forward to collaborating with you! 🚀
When chatting, please don't forget that we are human beings and that we do this with our own dedication and out of joy.
Cheers ❤️
pr-message: |
👋 Hii!
Welcome, and thank you for opening your first pull request with us! 🎉 We're thrilled to see your contribution.
Before we review, please ensure that:
- You've followed the [contribution guidelines](../blob/main/CONTRIBUTING.md).
- Your changes are thoroughly tested and documented (if applicable).
- The PR description includes all changes and necessary details for the reviewers.
Our team will review your submission as soon as possible.
In the meantime, feel free to ask any questions or provide additional context to help with the review process.
We appreciate your effort and look forward to collaborating with you! 🚀
When chatting, please don't forget that we are human beings and that we do this with our own dedication and out of joy.
Cheers ❤️
65 changes: 65 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: npm-publish
run-name: NPM build, test and publish

on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- 'package.json'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Bun.js
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Update bun dependencies
run: |
bun i
bun run build
bun run test --if-present
- name: Commit and push changes
uses: EndBug/add-and-commit@v9
with:
add: 'package*.json'
message: 'Bot: bun deps update'

- name: Store build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist
package*.json
publish-npmjs-com:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Bun.js
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: dist

- name: Publish to npmjs.com
run: bun publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# bun-router
# bun-route
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![typescript](https://img.shields.io/badge/dynamic/json?style=plastic&color=blue&label=Typescript&prefix=v&query=peerDependencies.typescript&url=https%3A%2F%2Fraw.githubusercontent.com%2Fnoblemajo%2Fbun-router%2Fmain%2Fpackage.json)
![](https://img.shields.io/badge/dynamic/json?color=green&label=watchers&query=watchers&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-router)
![](https://img.shields.io/badge/dynamic/json?color=yellow&label=stars&query=stargazers_count&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-router)
![](https://img.shields.io/badge/dynamic/json?color=navy&label=forks&query=forks&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-router)
<!-- ![](https://img.shields.io/badge/dynamic/json?color=darkred&label=open%20issues&query=open_issues&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-router)
![](https://img.shields.io/badge/dynamic/json?color=orange&label=subscribers&query=subscribers_count&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-router) -->
![typescript](https://img.shields.io/badge/dynamic/json?style=plastic&color=blue&label=Typescript&prefix=v&query=peerDependencies.typescript&url=https%3A%2F%2Fraw.githubusercontent.com%2Fnoblemajo%2Fbun-route%2Fmain%2Fpackage.json)
![](https://img.shields.io/badge/dynamic/json?color=green&label=watchers&query=watchers&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)
![](https://img.shields.io/badge/dynamic/json?color=yellow&label=stars&query=stargazers_count&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)
![](https://img.shields.io/badge/dynamic/json?color=navy&label=forks&query=forks&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)
<!-- ![](https://img.shields.io/badge/dynamic/json?color=darkred&label=open%20issues&query=open_issues&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)
![](https://img.shields.io/badge/dynamic/json?color=orange&label=subscribers&query=subscribers_count&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route) -->

**A fast, Express-like router for the high-performance `bun.serve()` HTTP server.**

Bun-Router leverages Bun.js's powerful `bun.serve` to deliver a fast, familiar, and reliable routing experience. It provides developers with an easy-to-use, Express-like API, tailored for high-performance applications built with Bun.js.
`bun-route` leverages Bun.js's powerful `bun.serve` to deliver a fast, familiar, and reliable routing experience. It provides developers with an easy-to-use, Express-like API, tailored for high-performance applications built with Bun.js.

*At the **time of Bun-Router's creation**, Bun.js did not include a built-in router, so Bun-Router was designed as a lightweight, dependency-free solution to fill that gap.*
*At the **time of `bun-route`'s creation**, Bun.js did not include a built-in router, so `bun-route` was designed as a lightweight, dependency-free solution to fill that gap.*

# features

Expand All @@ -20,14 +20,14 @@ Bun-Router leverages Bun.js's powerful `bun.serve` to deliver a fast, familiar,
- **wildcards**: Can handle double wildcards (`**`) as any recursive path and
single wildcards (`*`) as any path part. *It also provides a path parameter string array".*
If enabled, cookies can also automatically be set/unset to the response headers.
- **static-serve**: Serves static files via a middleware ([example](https://github.com/NobleMajo/bun-router/blob/main/examples/static-serve.ts)).
- **static-serve**: Serves static files via a middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/static-serve.ts)).
- **dump-router**: You can create a string router dump that lists the defined routes.
If you provide a bun server, it also adds a `server-is-running-on` message.
- **basic-auth**: Protects the following via HTTP basic auth ([example](https://github.com/NobleMajo/bun-router/blob/main/examples/basic-auth.ts)).
- **cookie-handling**: Cookie parsing can be enabled via a middleware ([example](https://github.com/NobleMajo/bun-router/blob/main/examples/cookies.ts)).
- **basic-auth**: Protects the following via HTTP basic auth ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/basic-auth.ts)).
- **cookie-handling**: Cookie parsing can be enabled via a middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/cookies.ts)).
- **redirect-handler**: You can redirect via the `ResponseBuilder` or
via a redirect middleware ([example](https://github.com/NobleMajo/bun-router/blob/main/examples/redirect.ts)).
- **websocket-support**: Can handle websocket request via a middleware ([example](https://github.com/NobleMajo/bun-router/blob/main/examples/websocket.ts)).
via a redirect middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/redirect.ts)).
- **websocket-support**: Can handle websocket request via a middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/websocket.ts)).

## performance

Expand All @@ -42,19 +42,19 @@ Bun-Router leverages Bun.js's powerful `bun.serve` to deliver a fast, familiar,
## install

```sh
bun i github:NobleMajo/bun-router
bun i github:NobleMajo/bun-route
```

## import

```ts
import { Router } from "bun-router/src/index";
import { Router } from "bun-route/src/index";
```

## example

```ts
import { Router } from "bun-router/src/index";
import { Router } from "bun-route/src/index";

const router = new Router()

Expand All @@ -74,17 +74,17 @@ console.info(router.dump(server))

# examples

Checkout the bun-router [examples](https://github.com/NobleMajo/bun-router/tree/main/examples):
- [simple example](https://github.com/NobleMajo/bun-router/blob/main/examples/simple.ts)
- [static-serve example](https://github.com/NobleMajo/bun-router/blob/main/examples/static-serve.ts)
- [websocket example](https://github.com/NobleMajo/bun-router/blob/main/examples/websocket.ts)
- [redirect example](https://github.com/NobleMajo/bun-router/blob/main/examples/redirect.ts)
- [cookies example](https://github.com/NobleMajo/bun-router/blob/main/examples/cookies.ts)
- [basic auth example](https://github.com/NobleMajo/bun-router/blob/main/examples/basic-auth.ts)
Checkout the bun-route [examples](https://github.com/NobleMajo/bun-route/tree/main/examples):
- [simple example](https://github.com/NobleMajo/bun-route/blob/main/examples/simple.ts)
- [static-serve example](https://github.com/NobleMajo/bun-route/blob/main/examples/static-serve.ts)
- [websocket example](https://github.com/NobleMajo/bun-route/blob/main/examples/websocket.ts)
- [redirect example](https://github.com/NobleMajo/bun-route/blob/main/examples/redirect.ts)
- [cookies example](https://github.com/NobleMajo/bun-route/blob/main/examples/cookies.ts)
- [basic auth example](https://github.com/NobleMajo/bun-route/blob/main/examples/basic-auth.ts)

Run a example:
```sh
git clone https://github.com/NobleMajo/bun-router.git
git clone https://github.com/NobleMajo/bun-route.git

bun run examples/simple.ts
```
Expand Down
Binary file modified bun.lockb
Binary file not shown.
41 changes: 35 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
{
"name": "bunrouter",
"version": "1.0.1",
"module": "src/index.ts",
"name": "bun-route",
"version": "1.0.14",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"description": "A fast, Express-like router for the high-performance bun.serve() HTTP server.",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"scripts": {
"test": "bun test"
"bump": "bun --print \"const pkg = await Bun.file('package.json').json(); pkg.version = pkg.version.split('.').map((v, i) => i===2?+v+1:v).join('.'); await Bun.write('package.json', JSON.stringify(pkg, null, 2)); export default pkg.version\"",
"test": "bun test",
"build": "bun run .github/build.ts"
},
"files": [
"dist"
],
"keywords": [
"bun"
],
"license": "MIT",
"homepage": "https://github.com/NobleMajo/bun-route",
"repository": {
"type": "git",
"url": "git+https://github.com/NobleMajo/bun-route.git"
},
"bugs": "https://github.com/NobleMajo/bun-route/issues",
"author": {
"name": "NobleMajo",
"email": "[email protected]",
"url": "https://noblemajo.de/en/"
},
"devDependencies": {
"@types/bun": "latest"
"bun-plugin-dts": "^0.3.0",
"@types/bun": "^1.1.10"
},
"peerDependencies": {
"typescript": "^5.6.2"
}
}
}
Loading

0 comments on commit 73a6110

Please sign in to comment.