blob: 15ef72cc6e034bea3cb2a38ce627076d2f4a63fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
---
name: Build an HTTP server using StricJS and Bun
---
[StricJS](https://github.com/bunsvr) is a Bun framework for building high-performance web applications and APIs.
- **Fast** — Stric is one of the fastest Bun frameworks. See [benchmark](https://github.com/bunsvr/benchmark) for more details.
- **Minimal** — The basic components like `@stricjs/router` and `@stricjs/utils` are under 50kB and require no external dependencies.
- **Extensible** — Stric includes with a plugin system, dependency injection, and optional optimizations for handling requests.
---
Use `bun init` to create an empty project.
```bash
$ mkdir myapp
$ cd myapp
$ bun init
$ bun add @stricjs/router
```
---
To implement a simple HTTP server with StricJS:
```ts#index.ts
import { Router } from '@stricjs/router';
export default new Router()
.get('/', () => new Response('Hi'));
```
---
To serve static files from `/public/*`:
```ts#index.ts
export default new Router()
.get('/', () => new Response('Hi'))
.get('/public/*', stream('.'));
```
---
Run the file in watch mode to start the development server.
```bash
$ bun --watch run index.ts
```
---
For more info, see Stric's [documentation](https://stricjs.gitbook.io/docs).
|