1.0.5 • Published 6 years ago

languid v1.0.5

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

languid

Coverage Status Build Status

A simple web framework, made for REST/JSON APIs

Installation

npm install --save languid

Usage

const languid = require('languid')
const Promise = require('bluebird')

const app = languid()

app.get('/', req => {
  console.log(req.headers)
  console.log(req.body)
  console.log(req.query)
  // the return of the promise chain
  // will be the response
  return Promise.resolve({
    statusCode: 200,
    headers: {
      stuff:'content',
    },
    body: {
      ok: 'ok',
    },
  })
})

app.post('/dino', req => {
  console.log(req.headers)
  console.log(req.body)
  console.log(req.query)
  return Promise.resolve({
    statusCode: 201,
    body: req.body,
  })
    .then(response => {
      throw new Error()
    })
    .catch(error => {
      // this will be the new response
      return {
        statusCode: 500,
        body: {
          message: 'Internal Server Error',
        },
      }
    })
})

app.post('/bla', req => {
  console.log(req.headers)
  console.log(req.body)
  console.log(req.query)
  return Promise.resolve({
    statusCode: 404,
    body: {
      got: 'bla',
    },
  })
})

app.listen(8000)
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago