Coder Social home page Coder Social logo

ujjwalguptaofficial / fortjs Goto Github PK

View Code? Open in Web Editor NEW
71.0 6.0 12.0 5.68 MB

A feature-rich Node.js web framework designed for building powerful, scalable, and maintainable web applications.

Home Page: https://fortjs.net/

License: MIT License

TypeScript 64.31% JavaScript 32.91% HTML 2.70% Shell 0.08%
nodejs-server typescript server nodejs-framework nodejs typescript-framework nodejs-typescript framework mvc-framework es6

fortjs's Introduction

GitHub version TEST npm version Docs

Fortjs

Fortjs is efficient web framework for Node.js that empowers developers to build scalable and performant applications with ease. With a focus on simplicity and speed, fortjs provides a robust foundation for creating web APIs and applications. Featuring intuitive routing, dependency injection, and a powerful middleware system, fortjs allows you to craft clean, organized architectures.

Benchmark

BENCHMARK

Fortjs is 3x faster than express and nestjs both.

Check live test on GITHUB CI

Author's Note

While Node.js is undeniably powerful, its available frameworks and ecosystem often lead developers to focus solely on building the application, neglecting considerations for long-term maintainability and code cleanliness. The resulting codebase can be challenging for new team members to grasp.

In contrast, ecosystems like Java and C# offer robust frameworks that facilitate the creation of more maintainable applications. These ecosystems enable new employees to work on the product with relative ease, even without an in-depth understanding of the entire codebase.

Fort.js aims to address this issue by leveraging modern JavaScript and TypeScript. It provides simple APIs and adopts the Fort architecture, which promotes modularity through components without compromising performance (reportedly 3 times faster than Express.js).

Why fortjs

  1. Simplicity: fortjs embraces simplicity, making it easy for developers to understand and use.

  2. Efficiency: The framework is designed for efficiency, enabling the development of performant applications.

  3. Scalability: fortjs provides a scalable architecture for building both small and large web applications.

  4. Faster: Fortjs delivers unparalleled speed, surpassing popular alternatives like Express and Nest by more than two times, providing a high-performance solution for web applications. Take a look at Benchmark

  5. Reusable Components: Components like walls, shields, and guards offer a modular and reusable approach to building applications.

  6. Intuitive Routing: fortjs simplifies routing, making it intuitive for developers to define and manage routes.

  7. Dependency Injection: The framework includes a robust dependency injection system, promoting clean and organized code.

  8. Unit Testable: Fort.js is designed to be unit-testable, enabling developers to write tests for their code, ensuring stability and maintainability.

  9. Authentication and Authorization: Guards facilitate the management of authentication and authorization, enhancing security.

  10. Modern Development: fortjs is built with modern development practices in mind, providing a contemporary and efficient development experience.

  11. Boilerplate Reduction: Developers can say goodbye to boilerplate code, resulting in cleaner and more maintainable codebases.

  12. Flexibility: fortjs offers flexibility in how components are used, allowing developers to tailor the framework to their specific needs. You can configure almost everything.

  13. Fort Architecture: fortjs follows a well-architected design Fort , promoting a structured and organized development approach.

  14. TypeScript Supported: With native TypeScript support, fortjs empowers developers to leverage the benefits of static typing for a more robust and error-resistant codebase.

Docs

https://fortjs.net/

Examples

Fortjs provides example for different scenario and tools. Check out repo - https://github.com/ujjwalguptaofficial/fortjs-examples

Help

We are here to help you. Ask any question at github discussion

Stay in touch

Contributors

You are very welcome to contribute, please see contributing guidelines - [Contribute].

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. For sponsoring, contact author of this project.

fortjs's People

Contributors

dependabot[bot] avatar grossacasac avatar ujjwalguptaofficial avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fortjs's Issues

Feature Request: Adding type to HttpResult

Currently the HttpResult has a property "responseData" which is of type any, This feature request is to add type support in HttpResult so that the user of the library could pass the DTO class type for the "responseData" object.

Async Promise antipattern is used

On this line https://github.com/ujjwalguptaofficial/fortjs/blob/master/src/handlers/request_handler.ts#L185

    async handlePostData() {
        if (this.request.method === HTTP_METHOD.Get) {
            this.body = {};
        }
        else if (Global.shouldParsePost === true) {
            try {
                this.body = await this.parsePostData();
            }
            catch (ex) {
                return Promise.reject(ex);
            }
        }
    }

Things to know about Promises:

  1. Promises are flattened by default. (Think flat map). So:
    Promise.reject(Promise.reject("error")) is the same as Promise.reject("error") and Promise.resolve(Promise.resolve("value")) is the same as Promise.resolve("value")
    Promise.resolve(Promise.reject("error")) is the same as Promise.reject("error")
  2. Async function will wrap any returned value in a Promise.resolve and any thrown value in a Promise.reject

So inside the else if it could be rewritten

            try {
                this.body = await this.parsePostData();
            }
            catch (ex) {
                throw ex;
            }
  1. Also, any function that throws will propagate the error down the stack trace until a catch is found. It means it is useless to have catch (x) { throw x;}

So even simpler

`this.body = await this.parsePostData();            

The code will execute the same. Next steps fix other places that use this antipattern

Not working with many checkbox radio ?

Hello i need help,
I would like use many checkbox but when i click to checkbox one and checkbox two is not working.

I have a form with a lot of radio buttons they are all in classes
The problem is that when I click on the first radio button it works but when I click on the second one and well the Progress bar doesn't advance.
and I can have forms with 10 checkboxes as 6 is random how to make it automatic?

[]( check -->https://jsfiddle.net/alex447/m6juh0dx/19/ )

` function flash(){
function cback(e) {
var t = [];
for (var n = inputs.length; n--;) {
if (!inputs[n].value.length) t.push(inputs[n]);
}
var r = t.length;
var i = inputs.length;
var s = document.querySelectorAll(".top");
for (var o = s.length; o--;) {
s[o].style.width = 100 - r / i * 100 + "%";
s[o].style.background = cols[i-r-1];
}
}
var forms = document.querySelectorAll(".form"),
inputs = [];
for (var i = forms.length; i--;) {
var els = forms[i].querySelectorAll("input, textarea, select");
for (var j = els.length; j--;) {
if (els[j].type != "button" && els[j].type != "submit") {
inputs.push(els[j]);
els[j].addEventListener("input", cback, false);
}
}
}

var cols = ["#1ABC9C","#EC7063","#3498DB"];
}

function gradient(){
function cback(e) {
var t = [];
for (var n = inputs.length; n--;) {
if (!inputs[n].value.length) t.push(inputs[n]);
}
var r = t.length;
var i = inputs.length;
var s = document.querySelectorAll(".top");
for (var o = s.length; o--;) {
s[o].style.width = 100 - r / i * 100 + "%";
}
}
var forms = document.querySelectorAll(".form"),
inputs = [];
for (var i = forms.length; i--;) {
var els = forms[i].querySelectorAll("input, textarea, select");
for (var j = els.length; j--;) {
if (els[j].type != "button" && els[j].type != "submit") {
inputs.push(els[j]);
els[j].addEventListener("input", cback, false);
}
}
}
}
function sections(){
function cback(e) {
var t = [];
for (var n = inputs.length; n--;) {
if (!inputs[n].value.length) t.push(inputs[n]);
}
var r = t.length;
var i = inputs.length;
var s = document.querySelectorAll(".top");
for (var o = s.length; o--;) {
s[o].style.width = 100 - r / i * 100 + "%";
}
}
var forms = document.querySelectorAll(".form"),
inputs = [];
for (var i = forms.length; i--;) {
var els = forms[i].querySelectorAll("input, radio, select");
for (var j = els.length; j--;) {
if (els[j].type != "button" && els[j].type != "submit") {
inputs.push(els[j]);
els[j].addEventListener("input", cback, false);
}
}
}

function generateCSSGradient(colours) {
var l = colours.length, i;
for( i=0; i<l; i++) colours[i] = colours[i].join(" ");
return "linear-gradient( to right, "+colours.join(", ")+")";
}

var cols = [
["#1ABC9C","0%"],
["#1ABC9C","33.3%"],
["#EC7063","33.3%"], // note same percentage - this gives a crisp change
["#EC7063","66.6%"],
["#3498DB","66.6%"],
["#3498DB","100%"]
];
document.getElementsByClassName('.top').innerHTML = '

';
document.querySelector(".colors").style.background = generateCSSGradient(cols);

var window_width = window.innerWidth + "px";
document.querySelector(".colors").style.width = window_width;

};`

Thanks

Dependency injection stops working when using more than 2 singletons in a controller

I have 3 services right now that I need to inject into my controller. Problem is when I use a third one it'll just stop injecting all together.
Example:

getOrderService: GetOrderService
updateOrderService: UpdateOrderService
createOrderService: CreateOrderService

constructor(
    @Singleton(CreateOrderService) createOrderService: CreateOrderService,
    @Singleton(GetOrderService) getOrderService: GetOrderService,
    @Singleton(UpdateOrderService) updateOrderService: UpdateOrderService) {
          super();
          this.getOrderService = getOrderService;
          this.createOrderService = createOrderService;
          this.updateOrderService = updateOrderService;
}

returns on every request:
internal server error message : this.getOrderService.<<whatever.function.is.called>> is not a function stacktrace: TypeError: this.getOrderService.<<whatever.function.is.called>> is not a function at OrderController. (C:\Users\weltert\Desktop\pba-api-test\pba-api\bin\app.js:285:60) at step (C:\Users\weltert\Desktop\pba-api-test\pba-api\bin\app.js:221:23) at Object.next (C:\Users\weltert\Desktop\pba-api-test\pba-api\bin\app.js:202:53) at C:\Users\weltert\Desktop\pba-api-test\pba-api\bin\app.js:196:71 at new Promise () at ./controllers/order_controller.ts.__awaiter (C:\Users\weltert\Desktop\pba-api-test\pba-api\bin\app.js:192:12) at OrderController../controllers/order_controller.ts.OrderController.<<whatever.function.is.called>>(C:\Users\weltert\Desktop\pba-api-test\pba-api\bin\app.js:281:16) at RequestHandler.module.exports.RequestHandler.runController_ (C:\Users\weltert\Desktop\pba-api-test\pba-api\node_modules\fortjs\dist\fort.js:2162:67) at RequestHandler. (C:\Users\weltert\Desktop\pba-api-test\pba-api\node_modules\fortjs\dist\fort.js:2322:34) at step (C:\Users\weltert\Desktop\pba-api-test\pba-api\node_modules\fortjs\dist\fort.js:2069:23) at Object.next (C:\Users\weltert\Desktop\pba-api-test\pba-api\node_modules\fortjs\dist\fort.js:2050:53) at fulfilled (C:\Users\weltert\Desktop\pba-api-test\pba-api\node_modules\fortjs\dist\fort.js:2041:58)

But if I remove 1 singleton (doesn't matter which):

getOrderService: GetOrderService
updateOrderService: UpdateOrderService

constructor(
    @Singleton(CreateOrderService) createOrderService: CreateOrderService,
    @Singleton(GetOrderService) getOrderService: GetOrderService) {
       super();
          this.getOrderService = getOrderService;
          this.createOrderService = createOrderService;
}

It'll work just fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.