# httptree

> Web framework to make http modules easier to use

Latest version **0.0.3** (published 2023-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install httptree
pnpm add httptree
yarn add httptree
bun add httptree
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-06-04 |
| First published | 2022-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 26.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | esctabcapslock |
| Maintainers | esctabcapslock |

## Links

- npm: https://www.npmjs.com/package/httptree
- Repository: https://github.com/esctabcapslock/httptree
- Issues: https://github.com/esctabcapslock/httptree/issues
- npm.io page: https://npm.io/package/httptree

## Recent versions

- 0.0.3 (latest) — 2023-06-04
- 0.0.2 — 2023-03-11
- 0.0.1 — 2022-07-14

## README

<div align="center">

# httptree 🌲
[![npm](https://img.shields.io/npm/v/httptree.svg)](https://www.npmjs.com/package/httptree)
Web framework to make [http] and [https] modules easier to use
</div>

## Feature
- Referred to [express](express), excellent  web framework 
- Created for use in my some another project
- Modularization of server Routing logic

## Usage
- A small example of running a server ([also check this](./example/example.js))
```js
//@ts-check
const httptree = require('../lib')
const http = require('http')

// creage httptree module
const hp = new httptree.Server() 
const port = 3000

// add get methon in '/' path
hp.get((req,res,data,obj)=>{ 
    console.log('res / ans',res.statusCode)
    res.send('<a href="#">hello httptree!!</a>')
})
hp.path('index.html').get((req,res,data,obj)=>{

    // Existing functions inside  http module can be used.
    res.setHeader('Access-Control-Allow-Origin','*')
    console.log('res index.html',res.statusCode, data)
    res.sendFile(__dirname+'\\index.html')
})

console.log('this structure:',hp.printStructure())
http.createServer((req,res)=>{ 
    console.log('req:',req.url)

    // hp.parse return boolean that Whether it sent a reply to the client
    return hp.parse(req,res,{}) ||

    // httptree.httpError is simple http error handler
    httptree.httpError(404,res,'not file')

}).listen(port,()=>console.log('server port:',port))
```



[http]: https://nodejs.org/dist/latest-v16.x/docs/api/http.html
[https]: https://nodejs.org/dist/latest-v16.x/docs/api/https.html

---
_Source: https://npm.io/package/httptree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
