Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eldoy/furu
Extraordinary Web Server
https://github.com/eldoy/furu
Last synced: 6 days ago
JSON representation
Extraordinary Web Server
- Host: GitHub
- URL: https://github.com/eldoy/furu
- Owner: eldoy
- Created: 2022-04-09T01:44:18.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-12T18:34:45.000Z (2 months ago)
- Last Synced: 2024-09-13T08:05:29.616Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 78.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
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)