11 releases

0.3.1 Apr 13, 2024
0.3.0 Dec 27, 2023
0.2.8 Nov 26, 2023
0.2.1 Oct 21, 2023
0.0.2 Sep 6, 2023

#312 in HTTP server

Download history 4/week @ 2023-12-31 11/week @ 2024-02-11 18/week @ 2024-02-18 9/week @ 2024-02-25 1/week @ 2024-03-10 7/week @ 2024-03-31 156/week @ 2024-04-07 41/week @ 2024-04-14

204 downloads per month

MIT license

15KB
228 lines

ngyn (en·jn)

Crates.io Docs.rs License MSRV

A progressive framework in Rust for building scalable web applications through an opinionated architecture.

More information about Ngyn can be found in the documentation.

Features

  • Macro API for organizing your application into reusable components
  • Built-in dependency injection for managing your application's dependencies
  • Asynchronous middleware for handling requests and responses
  • Asynchronous routing for defining your application's endpoints
  • Platform-agnostic for supporting multiple libraries and frameworks

Please note that Ngyn is still in its early stages of development, and the API is subject to change.

Example

This example demonstrates how to create a simple web server using Ngyn and Tide. To use Ngyn with Tide, you must enable the tide feature in your Cargo.toml file.

[dependencies]
ngyn = { version = "0.3.0", features = ["tide"] }
nject = "0.3.0"

And here's the code:

use ngyn::{
	platforms::{NgynApplication, Result},
	prelude::*
};

#[controller]
struct MyController;

#[routes]
impl MyController {
    #[get("/")]
    fn index(&self) {
        "Hello World!".to_string()
    }

    #[get("/hello/:name")]
    fn hello(&self) {
        let name = request.param("name").unwrap();
        format!("Hello, {}!", name)
    }
}

#[module(controllers = [MyController])]
struct MyAppModule;

#[main]
async fn main() -> Result<()> {
    let app = NgynFactory::<NgynApplication>::create::<MyAppModule>();

    app.listen("127.0.0.1:8080").await?;

    Ok(())
}

Philosophy

Description

Ngyn proposes an opinionated, modular, and scalable architecture, largely inspired by NestJS and structured around the concept of modules - discrete, reusable components that collectively shape an application. These modules, each addressing specific functionalities, can be nested to form a functional hierarchy. This modular design simplifies application organization and enhances reusability across various projects.

Platform Agnosticism

A platform (more properly called platform engine) in Ngyn refers to the underlying library or framework that is used to build your application. For example, you could build your application using Actix or Warp or Tide, and each of these platforms would provide a different set of features for building your application.

By default, Ngyn uses Tide as its underlying platform. However, you're not limited to this and can choose to also create your own platform engines.

Contribution

Ngyn is an open-source project, and we welcome contributions from the community. Feel free to report issues, suggest enhancements, or submit pull requests to help us improve Ngyn.

License

Ngyn is licensed under the MIT License, allowing you to use, modify, and distribute the framework freely.

Dependencies

~7–23MB
~339K SLoC