Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eldoy/furu

Extraordinary Web Server
https://github.com/eldoy/furu

Last synced: 6 days ago
JSON representation

Extraordinary Web Server

Awesome Lists containing this project

README

        

# Furu Web Server

Extraordinary Javascript Web Server.

Adds what's missing from the built in web server of NodeJS:

* Body parameters and file uploads
* Cookies
* Cors
* Middleware
* Language
* Redirects
* Mime types
* Request store
* Routes
* Static files
* Extra properties:
- IP address
- pathname
- protocol
* And more!

The server is extremely fast and minimal.

Check out the [Furu example app here.](https://github.com/eldoy/furu-test)

### Install
```
npm i furu
```

### Usage

Minimal usage example:
```js
async function handleRequest(req, res) {
if (req.pathname == '/hello') {
return { hello: 'world' }
}
}

// The server object is a vanilla NodeJS HTTP server
var server = furu({ port: 9000 }, handleRequest)
```

More advanced example with pages, layouts and assets:
```js
var furu = require('furu')
var layout = require('./app/layouts/main.js')
var homePage = require('./app/pages/home.js')
var aboutPage = require('./app/pages/about.js')

var routes = {
'get#/': homePage,
'get#/about': aboutPage
}

async function handleRequest(req, res) {
if (req.route) {
var html = await req.route(req, res)
return layout(html)
}
}

var options = { port: 9095, dir: 'app/assets', routes }

furu(options, handleRequest)
```

ISC Licensed. Enjoy!

Created by [Eldøy Projects](https://eldoy.com)