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

moon-boot

v0.0.11

Published

> A Project followed by SpringBoot For Nodejs

Downloads

3

Readme

moon-boot

What

A Project followed by SpringBoot For Nodejs

Why

  1. SpringBoot is the most popular Microservice Framework.
  2. By IOC, It's simply to organize your project structure.

How to use

const { start } = require('moon-boot')
start(__dirname)
// For Class Mode
const { start } = require('moon-boot')
class Main {
  constructor() {
    start(__dirname)
  }
}
new Main()

We suggest the second way to use this. For Decorator is easy to use with less code, is right?

Create with npx

$ npx create-moon-boot myProject

Decorator

  1. LifeCycleHooks AfterScan AfterEnv AfterLog BeforeStart AfterStart

  2. @Value To load env as Param

    @Bean()
    class TestService {
      @Value('profiles.active')
      activeProfile!: string
    
      // Give a placeholder
      @Value('server.port:8080')
      activeProfile!: string
    
      // Transform Type
      @Value('someData:{"name":"anc"}', { type: User })
      someData!: User
    }
  3. @Autowired To load Beans

    @Bean()
    class TestService {
      @Autowired()
      test2Service: Test2Service
    
      @Autowired('test2Service')
      otherName: Test2Service
    }
  4. @Bean To Register Bean

    !!! difference: When Bean have not be used, it will not load

    @Bean('otherName')
    class TestService {}
  5. @BeforeBean To run before Bean register

    @BeforeBean((env) => {
      console.log(env)
    })
    @Bean('otherName')
    class TestService {}
  6. @Condition To run before Bean register, will no be load when return false

    @Condition((env) => {
      return '8080' === env('server.port')
    })
    @Bean('otherName')
    class TestService {}
  7. @Schedule Support node-schedule timed task for moon-boot

    @Bean()
    class TestService {
      @Schedule('0 * * * * *')
      test() {
        return 'run in cron'
      }
    }

Plugins

How to build plugins? See @moon-boot/plugin-express as example If you want register, you must provide bean to be scaned from index

  1. Rest => @moonboot/plugin-express

    // This Moudle will auto use when installed
    // See project For More Information
    // index.ts
    import { start } from 'moon-boot'
    class Main {
      constructor() {
        start(__dirname)
      }
    }
    new Main()
    // controller.ts
    @Controller()
    class TestController {
      @Get('test/:id')
      test(@Body(UserParam) userParam: UserParam) {
        return 'success'
      }
    }
  2. Redis => @moonboot/plugin-redis

    @Bean()
    class TestService {
      @Autowired()
      redisTemplate!: RedisTemplte
    
      test() {
        return this.redisTemplate.mget()
      }
    }
  3. Mysql => @moonboot/plugin-mysql

    @Bean()
    class TestService {
      @Autowired()
      mysqlTemplate!: MysqlTemplate
    
      test() {
        return this.mysqlTemplate.query()
      }
    }
  4. Mysql => @moonboot/plugin-mysql-mybatis

    // TestService
    @Bean()
    class TestService {
      @Autowired()
      testMapper!: TestMapper
    
      test() {
        return this.testMapper.query()
      }
    }
    // TestMapper
    class User {
      @Alias('user_name')
      userName: string
    }
    @Bean()
    class TestMapper {
      @Select('select 1 from dual')
      @Type([Array, User])
      test(): Promise<User[]> {
        return this.testMapper.query()
      }
    }

FAQ

Q: Why use Decorator A: Simple

Q: Why not nestjs A: It works well, but in some case, It's too big.

LifeCycle

  1. Scan We will scan the directory you provide, and the node_modules align with package moon-boot and startsWith @moon-boot/
  2. Hook AfterScan
  3. Env We will scan the directory you provide, to find application.yma?l
  4. Hook AfterEnv
  5. Log Load log4js
  6. Hook AfterLog
  7. Hook BeforeStart
  8. Hook AfterStart