Skip to content

Commit c0e5925

Browse files
v1rtlv1rtl
authored andcommitted
add logo and prettify readme
1 parent cf99ea9 commit c0e5925

9 files changed

Lines changed: 1433 additions & 45 deletions

File tree

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
![](assets/cover.jpg)
2+
3+
![Twitter](https://img.shields.io/twitter/follow/v1rtl.svg?label=sub%20to%20twitter&style=flat-square) ![npm type definitions](https://img.shields.io/npm/types/@tinyhttp/app?style=flat-square)
4+
![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/body-parsec.svg?style=flat-square)
5+
![Last commit](https://img.shields.io/github/last-commit/talentlessguy/tinyhttp.svg?style=flat-square) ![NPM](https://img.shields.io/npm/l/@tinyhttp/app?style=flat-square)
6+
17
# tinyhttp
28

3-
work in progress
9+
> ⚠ The project is incomplete. Please don't use in production.
10+
11+
**tinyhttp** is a modern Express-like web framework for Node.js. It uses a bare minimum amount of dependencies trying to avoid legacy.
412

5-
A tiny Express remake, written in TypeScript.
13+
## Installation
14+
15+
Node.js 14 is required.
16+
17+
```sh
18+
# npm
19+
npm i @tinyhttp/app
20+
# pnpm
21+
pnpm i @tinyhttp/app
22+
# yarn
23+
yarn add @tinyhttp/app
24+
```
625

726
## Features
827

@@ -12,16 +31,38 @@ A tiny Express remake, written in TypeScript.
1231
- Smaller size
1332
- 0 legacy dependencies
1433

34+
## Docs
35+
36+
Coming soon...
37+
1538
## Example
1639

40+
At the moment there is only one basic example. I will add more of them once I add all the existing Express `req` / `res` extensions.
41+
1742
```ts
1843
import { App } from '@tinyhttp/app'
19-
import logger from '@tinyhttp/logger'
2044
import staticFolder from '@tinyhttp/static'
45+
import logger from '@tinyhttp/logger'
2146

2247
const app = new App()
2348

24-
app.all('/', (_, res) => res.send('<h1>Hello World</h1>'))
49+
app.all('/', (req, res) => {
50+
res.status(200).send(`
51+
<h1>tinyhttp example</h1>
52+
<ul>
53+
<li>Protocol: ${req.protocol}</li>
54+
<li>HTTPS: ${req.secure ? 'yes' : 'no'}</li>
55+
<li>URL: ${req.url}</li>
56+
<li>Method: ${req.method}</li>
57+
<li>Host: ${req.hostname}</li>
58+
<li>Status: ${res.statusCode}</li>
59+
</ul>
60+
<h2>Request headers</h2>
61+
<pre>
62+
${JSON.stringify(req.headers, null, 2)}
63+
</pre>
64+
`)
65+
})
2566

2667
app.get('/:first/:second', (req, res) => {
2768
res.json({ URLParams: req.params, QueryParams: req.query })

assets/cover.jpg

174 KB
Loading

assets/logo.svg

Lines changed: 14 additions & 0 deletions
Loading

examples/basic/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { App } from '../../packages/app/src/index'
22
import staticFolder from '../../packages/static/index'
33
import logger from '../../packages/logger/index'
4-
import { parse } from 'url'
54

65
const app = new App()
76

packages/cors/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Handler, METHODS } from '@tinyhttp/app'
1+
import { Handler, METHODS, Request, Response } from '@tinyhttp/app'
22

33
const cors = ({ host = '*', methods = METHODS, headers = ['Origin', 'X-Requested-With', 'Content-Type'] }): Handler => {
44
const prefix = 'Access-Control-Allow'
55

6-
return (_, res) => {
6+
return (_: Request, res: Response) => {
77
res.setHeader(`${prefix}-Origin`, host)
88
res.setHeader(`${prefix}-Headers`, headers.join(', '))
99
res.setHeader(`${prefix}-Methods`, methods.join(', '))

packages/cors/pnpm-lock.yaml

Lines changed: 36 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)