mares-welder

1.0.41 • Public • Published

mares-welder

Mares framework의 중심이 되는 모듈로 express를 wrapping 합니다. 추후 해당 모듈은 리팩토링이 필요합니다. mares-welder를 이용하면 express는 바로 사용하지 않아도 됩니다.

Installation

npm install --save mares-welder

Example

/**
 * start application
 * @param {string} rootDir - project root dir
 * @returns {Promise<Express>}
 */
async startApp = (rootDir) => {
	
	// mares module을 불러옵니다.
    const accountContext = reuiqre('../module-account')
    const senderContext = reuiqre('../module-sender')
    const MaresWelder = require('mares-welder')
    
    // 프로젝트 최상단 경로와 함께 mares instace를 생성합니다.
    const mares = new MaresWelder('root path')
    
    // express error handler를 등록해줍니다.
    mares.bindExpressErrorHandler((error, req, res, next) => {
        //todo    	
    })
    
    // 모듈을 추가합니다.
    mares.attach(accountContext, 1)
    mares.attach(senderContext, 1)
    mares.use((req, res, next) => {
    	// todo middleware
    	next()
    })
    
    // 모든 routing 되는 api의 앞에 apis url을 추가합니다.
    mares.setApiPrefix('apis')
    
    // 몽구스에 연결합니다.
    await mares.connectMongoose('mongoose url')
    
    // listen을 실행하여 express를 구동시킵니다.
    await mares.listen(settings.config['app'].port)

    // mongoose를 종료시킵니다.    
    await mares.getMongoose().disconnect()
    
    // express 서버를 종료시킵니다.
    await mares.disconnectApp()
}

Readme

Keywords

none

Package Sidebar

Install

npm i mares-welder

Weekly Downloads

0

Version

1.0.41

License

none

Unpacked Size

21.1 kB

Total Files

3

Last publish

Collaborators

  • hwaranglee
  • sngsng
  • piorio0919
  • kspark