sg-json-response

1.0.7 • Public • Published

sg-json-response

슬로그업 ddd에서 presentaion layer 에서 rest로 구현시 응답형태를 정의해 주는 모듈입니다.

Installation

npm install --save sg-json-response

Example

const app = require('express')()
const response = require('sg-json-response')
app.use(response())
(req, res, next) => {
	res.success(data) //200
	res.created(data) //201
	res.notfound(data) //404
	res.fail(data) //400, data is object
	res.fails(data) //400, data is array
	res.error(data) //500
	
	// status와 send를 동시에 호출
	res.sendObject(200, {
		age: 100,
		name: 'eric'
	})
}

Package Sidebar

Install

npm i sg-json-response

Weekly Downloads

0

Version

1.0.7

License

ISC

Unpacked Size

10.5 kB

Total Files

4

Last publish

Collaborators

  • hwaranglee
  • sngsng
  • piorio0919
  • kspark