npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tangos-core

v2.4.5

Published

https://appening.github.io/Tangos/

Downloads

20

Readme

Tangos

https://appening.github.io/Tangos/

NPM

Broilerplate code Node MongoDB server written in TypeScript

First things first

npm i tangos --save

Get all the CRUD operations along with end points just be extending our controller.

  • /find

    • request: {query(optional):YourQuery}
    • sample: {query:{name:"tej"}}
  • /findOne

    • request: {query(optional):YourQuery}
    • sample: {query:{_id:"yourmongodbobjecit"}}
  • /create

  • /update

    • request: {query(optional):YourQuery, data(must):YourData}

      Note: if you dont provide query, all the records within the collection will be updated

    • sample: {query:{name:"tej"}, data:{name:"tej2"}}

  • /deleteData

    • request: {query(optional):YourQuery}

      Note: if you dont provide query, all the records within the collection will be deleted

Architecture

MVP design pattern is used here.

Strictly typed.

Controller -> Presenter (Model).

Ever Controller/Router is linked with Presenter. Every Presenter is linked with Model.

Model has all the data about the collection . i.e Name of the collection, attributes...etc

Presenter does all the business logic i.e, Writing to database and returning the data as promise for every endpoint of that respective controller.

Running the Sample Application

  • Define your mongo creds in .env file
  • npm run dev (For running sample application)

Usage

1.Create your model by extending BaseModel

class Book extends BaseModel {
    collectionName: string = "books";
    schema: any = Book.getMongoSchema({name: String});


}

export default Book;

2.Create your presenter by extending the BasePresenter

class BookPresenter extends BasePresenter {

    constructor(baseModel: BaseModel) {
        super(baseModel);

    }

    public test():Promise<BaseResponse> {

        return new Promise<BaseResponse>((resolve => {
            resolve(BaseResponse.getSuccessResponse(null));
        }));
    }


}

export default BookPresenter;

3.Create your controller by extending the BaseController

class BookController extends BaseController<BookPresenter> {


    constructor(endPoint: string) {
        super(endPoint);
    }


    attachPresenter(): BookPresenter {
        return new BookPresenter(new Book());
    }

    attachCustomRoutes(): CustomRoute[] {
        let routes = [new CustomRoute("test", this.test.bind(this))];
        return routes;
    }

    test(web_req: express.Request, web_res: express.Response, next: express.NextFunction) {
        this.getPresenter().test();
        web_res.json({reached: 1});
    }

}

export default BookController;

4.Now add your controllers to server file

    let dbConfig = new DbConfig(MONGO_USER, MONGO_PASSWORD, MONGO_PATH, {});
    let config = new Config(false, []);
    let authConfig = new AuthConfig("somerandom");
    const app = new BaseApp(
        config,
        authConfig,
        dbConfig,
        [
            new BookController("/books"),
        ]
    );
    app.listen();

5.HOLAAAAAA ! Here we are in the END GAME

Middlewares 'N Layers

Middlewares mentioned below are default loaded in top to bottom order

  1. Logger Middleware

  2. Servertimeout Middleware (default is 5s)

  3. MongoDB Connection check Middleware

  4. Auth Middleware (JWT tokens are used and Configurable)

  5. Input Validation middlewares (Checks for proper JSON....etc)

  6. Base Controllers for common functionalities (User management, SMS/Email through AWS, Invoice Controller...etc Many more to come)

  7. $Your Controllers$, You can add any number of Validation middlewares before your controllers.

  8. Page not found (Route not found) handler Middleware.

  9. Exception handler Middleware (All the exceptions thrown in previous layers are caught here and handled).

  10. Analytics Middleware (Coming soon.)

Base Controller and Base Presenter

Exceptions

Base App

Middlewares

If you like my project, Star this and if you want to contribute mail me at [email protected] .

Thanks for stopping by ! :D !!

Regards

SaiTej Dandge

[email protected]