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

mixsts

v1.0.7

Published

MVC library for faster development for typescript

Downloads

14

Readme

Mixs.ts

MVC library for faster development for typescript

Let's start

Installation

npm install mixsts

init typescript tsconfig.json

tsc --init

We need to do some configuration in tsconfig.json

"experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
"emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */

Optional
"path":{
    "@mix":[
        "mixsts/core"
    ]
}

if you set path as above you need to insall tsconfig-paths npm packages or you can take a look inside node_modules/mixsts/libs exmple project structure

Folder's structure

libs
│   app.ts // contain server file
└───configs
│   │   app.ts
└───controllers
    │   app.controller.ts
    middlewares/
    etc...
    tsconfig.json

Simple usage

// configs/app.ts
import { setCoreConfig } from "@mix/config"

// app configuration
setCoreConfig({
    port:3000 // set app port
    
    // you can also set middlewares, aws, socket, etc... time to write
})
// app.ts
import "configs/app.ts"
import MixServer from "mixsts"

const mix = new MixServer()

mix.run() // start application

Let's create fitst controller

controllers/index.controllers.ts
import { Get, Controller } from "@mix/controllers"
import { Context } from "@mix/options"

@Controller("index") // localhost:3000/index
export default class IndexController {
    @Get()
    async index(context:Context) :Promise<void> {
        contex.json("Hello world")
    }
}

create global call controller and add controller to configs/app.ts

// configs/controllers.ts
import { controllerConfig, loadController } from "@mix/controllers"
loadController({
    require:[
        require("../controllers/index.controller.ts")
        // or set path in tsconfig.json for best practice
        require("@controllers/index.controller.ts")
    ]
})
export default controllerConfig
// configs/app.ts
import { setCoreConfig } from "@mix/config"
import controllerConfig from "./controllers"
// app configuration
setCoreConfig({
    port:3000 // set app port
    
    controllerConfig: controllerConfig
    // you can also set middlewares, aws, socket, etc... time to write
    
})

Socket.IO

// configs/app.ts
socket:{
    transport: ["websocket"]
}

Create event folder

// events/index.ts
import { OnConnection, OnDisconnect, OnEvent, OnEventError } from "@mix/socket";
import { Socket } from "socket.io";

export default class Event {
    @OnConnection()
    async onConnection(socket: any): Promise<void> {
        const socketId = socket.id // socket id
        socket.context = socket.handshake.auth
        console.log("connected:", socketId)
    }

    // @OnEventMiddleware(1)
    // async auth(socket: Socket, next: any): Promise<void> {
    //     next()
    // }

    @OnEventError()
    async onError(error: any, socket: Socket): Promise<void> {
        console.log(socket.id)
        console.log("error: ", error.message)
    }

    @OnDisconnect()
    async disconnect(socket: any): Promise<void> {
        console.log("Disconnected:", socket.id)
    }

    @OnEvent("chat")
    async chat(payload: any, socket: any): Promise<void> {
        console.log(payload)
        console.log(socket.id)
        // your logic here
    }

    @OnEvent("message")
    async message(payload: any, socket: any): Promise<void> {
        console.log(payload)
        console.log(socket.id)

        // your logic here
    }
}

 

add config file for socket global load

configs/events.ts
import { loadEvent, socketConfig } from "@mix/socket";

loadEvent({
    require: [
        require("@events/socket")
    ]
})

export default socketConfig

adjust configs/app.ts`

    socket: {
        transports: ["websocket"],
        enableConnectionLog: true,
        events: socketConfig
    }