0.22.8 • Published 4 months ago

linebridge v0.22.8

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

Linebridge

A multiproposal framework to build fast, scalable, and secure servers.

Currently used on RageStudio's services backends, like Comty

Suported Engines

  • hyper-express (default) | High Performance Node.js Webserver.
  • worker | IPC Worker for sharding and efficient multi-threading.

Features

  • Multiproposal architecture | Designed to adapt to different project needs.
  • Modular and Extensible | Easily add or replace components as needed.
  • 🚀 Fast & Scalable | Optimized for performance under high traffic.
  • 🔐 Secure by Default | Security-focused setup right out of the box.
  • 📡 Supports WebSockets | Real-time communication ready.
  • 📦 Multi-Protocol Support | Communicate over multiple protocols effortlessly.
  • 🔧 Built-in Transcompiler | Automatically transcompiles code on boot for smoother deployment.

Getting Started

Installation

npm install linebridge

!WARNING If you're using Yarn, you might encounter installation issues. We recommend using npm.

Example

Create a http server

// index.js
import { Server } from "linebridge"

class MyAPI extends Server {
    // set a id for the server
    static refName = "my-api"
    // define a file based router
    static routesPath = `${__dirname}/routes`
    // define custom listen port
    static listenPort = 3000

    // set manual routes
    routes = {
        // basic route
        "/hi": {
            method: "get",
            fn: async (req, res) => {
                return {
                    message: "Hello world"
                }
            }
        },
        // use custom middleware
        "/middleware-custom": {
            method: "get",
            middlewares: [
                "custom-middleware"
            ],
            fn: async (req, res) => {
                return {
                    message: "The middleware is working!"
                }
            }
        },
        // get from context
        "/db": {
            method: "get",
            useContexts: [
                "db"
            ],
            fn: async (req, res, ctx) => {
                console.log(ctx)
                return ctx.db.data
            }
        },
        // use parameters
        "/sum/:value1/:value2": {
            method: "get",
            fn: async (req, res) => {
                return {
                    result: parseInt(req.params.value1) + parseInt(req.params.value2)
                }
            }
        }
    }

    // define default middlewares to use on every request
    useMiddlewares = [
        async (req, res) => {
            console.log("Im executed every request")
        }
    ]

    // you can also define custom middlewares to use on endpoints
    middlewares = {
        "custom-middleware": async (req, res) => {
            console.log("Im a custom middleware")
        }
    }

    // define custom contexts to use on endpoints
    contexts = {
        db: {
            data: [
                {
                    id: 1,
                    name: "John Doe"
                },
                {
                    id: 2,
                    name: "Jane Doe"
                }
            ]
        }
    }

    async onInitialize() {
        console.log("Server initialized")
    }

    async onClose() {
        console.log("Server closed")
    }
}

Boot(MyAPI)

Run the server

linebridge-boot index.js

Documentation

The official documentation is on its way. Stay tuned for detailed guides and API references to help you unlock the full potential of Linebridge.

0.22.7

4 months ago

0.22.6

4 months ago

0.22.5

4 months ago

0.22.4

4 months ago

0.22.3

4 months ago

0.22.2

4 months ago

0.22.8

4 months ago

0.21.4

9 months ago

0.21.3

9 months ago

0.21.2

9 months ago

0.21.1

9 months ago

0.21.0

9 months ago

0.22.0

9 months ago

0.20.1

10 months ago

0.20.3

10 months ago

0.20.2

10 months ago

0.20.0

1 year ago

0.19.4

1 year ago

0.19.5

1 year ago

0.19.3

1 year ago

0.19.0

1 year ago

0.19.1

1 year ago

0.19.2

1 year ago

0.17.0

1 year ago

0.18.2

1 year ago

0.18.3

1 year ago

0.18.4

1 year ago

0.18.5

1 year ago

0.18.6

1 year ago

0.18.1

1 year ago

0.18.0

1 year ago

0.16.0

2 years ago

0.15.13

2 years ago

0.15.9

2 years ago

0.15.10

2 years ago

0.15.11

2 years ago

0.15.12

2 years ago

0.15.4

2 years ago

0.15.5

2 years ago

0.15.6

2 years ago

0.15.7

2 years ago

0.15.8

2 years ago

0.15.0

2 years ago

0.15.1

2 years ago

0.15.2

2 years ago

0.15.3

2 years ago

0.14.0

3 years ago

0.13.0

3 years ago

0.12.7

3 years ago

0.12.8

3 years ago

0.12.3

3 years ago

0.12.4

3 years ago

0.12.5

3 years ago

0.12.6

3 years ago

0.12.0

3 years ago

0.12.1

3 years ago

0.12.2

3 years ago

0.11.19

3 years ago

0.11.15

3 years ago

0.11.16

3 years ago

0.11.17

3 years ago

0.11.18

3 years ago

0.11.8

3 years ago

0.11.9

3 years ago

0.11.0

3 years ago

0.11.1

3 years ago

0.11.2

3 years ago

0.11.3

3 years ago

0.11.4

3 years ago

0.11.5

3 years ago

0.11.6

3 years ago

0.11.7

3 years ago

0.11.10

3 years ago

0.11.11

3 years ago

0.11.12

3 years ago

0.11.13

3 years ago

0.11.14

3 years ago

0.8.5

3 years ago

0.8.7

3 years ago

0.8.6

3 years ago

0.10.9

3 years ago

0.10.14

3 years ago

0.10.1

3 years ago

0.10.2

3 years ago

0.10.3

3 years ago

0.10.4

3 years ago

0.10.5

3 years ago

0.10.11

3 years ago

0.10.6

3 years ago

0.10.12

3 years ago

0.10.7

3 years ago

0.10.13

3 years ago

0.10.8

3 years ago

0.10.0

3 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.8.2

4 years ago

0.7.5

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.0

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.35

4 years ago