1.1.6 • Published 12 months ago

@byverdu/http-server v1.1.6

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months 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

12 months ago

1.1.0

12 months ago

1.1.6

12 months ago

1.1.5

12 months ago

1.1.4

12 months ago

1.0.70

12 months ago

1.0.19

2 years ago

1.0.2

2 years ago

1.0.18

2 years ago

1.0.1

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.60

2 years ago

1.0.44

2 years ago

1.0.22

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.20

2 years ago

1.0.69

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.24

2 years ago

1.0.45

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.32

2 years ago

1.0.10

2 years ago

1.0.31

2 years ago

1.0.15

2 years ago

1.0.58

2 years ago

1.0.14

2 years ago

1.0.0

2 years ago