Crates.io | ngyn |
lib.rs | ngyn |
version | 0.4.1 |
source | src |
created_at | 2023-09-06 22:46:58.116573 |
updated_at | 2024-07-07 16:11:24.981544 |
description | Modular backend framework for web applications |
homepage | |
repository | |
max_upload_size | |
id | 965742 |
size | 13,299 |
en·jn
)A progressive framework in Rust for building scalable web servers through an opinionated architecture.
More information about Ngyn can be found in the documentation.
Please note that Ngyn is still in its early stages of development, and the API is subject to change.
This example demonstrates how to create a simple web server using Ngyn and Hyper Platform.
[dependencies]
ngyn = { version = "0.4" }
And here's the code:
use ngyn::prelude::*;
use ngyn_hyper::HyperApplication;
#[controller]
struct MyController;
#[routes]
impl MyController {
#[get("/")]
fn index(&self) -> String {
"Hello World!".to_string()
}
#[get("/hello/<name>")]
fn hello(&self, param: Param) -> String {
let name = param.get("name").unwrap();
format!("Hello, {}!", name)
}
}
#[module(controllers = [MyController])]
struct MyAppModule;
#[main]
async fn main() {
let app = NgynFactory::<HyperApplication>::create::<MyAppModule>();
let _ = app.listen("127.0.0.1:8080").await;
}
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 organization and enhances reusability across various projects.
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 web server using Actix or Warp or Tide, and each of these platforms would provide a different set of features for building your web server.
By default, Ngyn uses Hyper as its underlying platform. However, you're not limited to this and can choose to also create your own platform engines.
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.
Ngyn is licensed under the MIT License, allowing you to use, modify, and distribute the framework freely.