All Projects → choko-org → redux-boot-webserver

choko-org / redux-boot-webserver

Licence: MIT license
Web server created using Redux Boot.

Programming Languages

javascript
184084 projects - #8 most used programming language

Redux Boot Web Server module.

Build Status

Web server created using Redux Boot as its core.

Install

npm install redux-boot-webserver --save

Actions constants

import {
  HTTP_BOOT,
  HTTP_REQUEST,
  HTTP_AFTER_BOOT
} from 'redux-boot-webserver'

Usage

import boot from 'redux-boot'
import webserverModule, {HTTP_REQUEST} from 'redux-boot-webserver'

const initialState = {
  variables: { port: 3020 }
}

const backendModule = {
  middleware: {
    [HTTP_REQUEST]: store => next => action => {
      const nextResult = next(action)
      const {response} = action.payload

      response.statusCode = 200
      response.setHeader('Content-Type', 'text/plain')
      response.end('Hello Motherfocas!')

      return nextResult
    }
  }
}

const modules = [
  webserverModule,
  backendModule
]

const app = boot(initialState, modules)
  .then(({store, action}) => {
    console.log('Your server is online!')
  })

Go to http://localhost:3020 and you should see the hello message.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].