Coder Social home page Coder Social logo

codyjdalton / litstack Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 2.0 520 KB

Typescript RESTful web service framework inspired by Angular and Spring Boot design patterns

License: MIT License

TypeScript 100.00%
typescript typescript-framework restful restful-webservices express restful-api spring-boot angular rest-api restapi ts

litstack's People

Contributors

codyjdalton avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

jsfix-ci

litstack's Issues

Add middleware at module level

An argument could be made that this could be done with next methods... could possibly close this if that meets the need.

Support "forRoot" global providers, auto-inject

Main use case for this is so the consumer can do:

@LitService()
class StorageService {

    constructor() {
        // .. do this once
        this.connect();
    }

    update() {
        // .. do something many times here
    }

    private connect() {
        // .. do something once here
    }
}

Currently, injecting the above service would give you a new instance of StorageService each time the component is new'd up (once per component route).

Could consider doing something like:

@LitModule({
    providers: [
        StorageService
    ]
})
export class CoreServicesModule {

}

Notice we don't have to make a custom forRoot() method like in Angular

And then in app.module:

@LitModule({
    imports: [
        CoreServicesModule
    ]
})
export class AppModule {

}

Now when you inject it in a component, it will have only constructed once.

This will require some changes to the Injector.resolve method, as well as the compiler.

Unable to use litstack v0.4.0

Describe the bug
Installing litstack v0.4.0 does not install the dist as it is ignored in npmignore

To Reproduce
Steps to reproduce the behavior:

  1. Type npm install
  2. Attempt to use the library

Limit requests at the endpoint / component / module level

Is your feature request related to a problem? Please describe.
In order to prevent DDOS/other attack vectors, it would be good to set a rate limit on the endpoint or module level

Describe the solution you'd like
What would be nice is if I could do something like the following:
For modules:

@LitModule({
    rateLimit: {
        windowMs: 15 * 60 * 1000, // 15 minutes
        max: 100 // limit each IP to 100 requests per windowMs
    },
    exports: [
       ...
    ],
    imports: [
        ...
    ]
})
export class AppModule {

}

For components, maybe something like:

@LitComponent({
    rateLimit: {
        windowMs: 15 * 60 * 1000, // 15 minutes
        max: 100 // limit each IP to 100 requests per windowMs
   }
})
export class AppComponent {
    @GetMapping({
        produces: AppConstants.MESSAGE_V1,
        rateLimit: {
              windowMs: 15 * 60 * 1000, // 15 minutes
              max: 100 // limit each IP to 100 requests per windowMs
        }
    })
    home(res: HttpResponse) {
        res.success({
            message: AppConstants.WELCOME_MESSAGE
        });
    }
}

Describe alternatives you've considered
Alternative would be to add a middleware to the application or endpoint handling the rate limiting

Allow request method stacking

The framework should allow for multiple requests types.

@RequestMapping({
    type: [ RequestMethods.GET, RequestMethods.DELETE ]
})

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.