1.1.6 • Published 2 years ago

@byverdu/http-server v1.1.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

npm Codecov Github lastCommit

http-server

This package is meant to be used as a quick way to setup an Express application. The module does not have too much defined. The default functionality is the following.

  • cors enabled
  • logs using morgan
  • static assets served from express.static('public')
  • /health endpoint to verify that the app is running.

Params

Pass an object with the following properties:

interface Route {
  method: 'get' | 'delete' | 'post' | 'put' | 'patch'
  path: string // must start with "/"
  handler: function(Request, Response)
}

interface Params {
  port?: number  // defaults to 3000
  middleware?: Array<Express middleware> // defaults to []
  routes: Array<Route>
}

How to use it

# install the module

> yarn add -D @byverdu/http-server
// index.js
import { httpServer } from "@byverdu/http-server";
import path from 'path';

const routes = [
  {
    method: 'get',
    path: '/some-path',
    handler: (req, res) => {

      res.sendFile(path.resolve('./index.html'))
    }
  }
]

httpServer({routes})

In order to serve static files create a public folder and place them inside there.

1.1.1

2 years ago

1.1.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.0.70

2 years ago

1.0.19

3 years ago

1.0.2

3 years ago

1.0.18

3 years ago

1.0.1

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.60

3 years ago

1.0.44

3 years ago

1.0.22

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.20

3 years ago

1.0.69

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.24

3 years ago

1.0.45

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.32

3 years ago

1.0.10

3 years ago

1.0.31

3 years ago

1.0.15

3 years ago

1.0.58

3 years ago

1.0.14

3 years ago

1.0.0

3 years ago