Skip to content

Commit e343b79

Browse files
authored
Merge pull request #13 from SecJS/feat/len-implement-fastify
feat: implement fastify as http server
2 parents dae3645 + f31bdc5 commit e343b79

21 files changed

Lines changed: 2094 additions & 443 deletions

README.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,32 @@ The intention behind this repository is to always maintain a `Http` package to a
2323

2424
<img src=".github/http.png" width="200px" align="right" hspace="30px" vspace="100px">
2525

26-
## WARN 🛑⚠️
27-
28-
> This project is under `development` do not use it until releases v1.0.0.
29-
3026
## Installation
3127

32-
> To use the high potential from @secjs/http you need to install first this packages from SecJS,
33-
> it keeps as dev dependency because one day @secjs/core will install everything once.
34-
35-
```bash
36-
npm install @secjs/contracts @secjs/utils
37-
```
38-
3928
```bash
4029
npm install @secjs/http
4130
```
4231

4332
## Usage
4433

45-
### SecJS
34+
### Http
4635

47-
> Use SecJS to create the Http server and map all your routes with handlers
36+
> Use Http class to create the http server and map all your routes
4837
4938
```ts
50-
import { SecJS } from '@secjs/http'
51-
import { SecContextContract } from '@secjs/contracts'
39+
import { Http, ContextContract } from '@secjs/http'
40+
41+
const server = new Http()
5242

53-
const server = new SecJS()
43+
server.use(ctx => ctx.data.param = 'param')
5444

55-
server.get('/', (ctx: SecContextContract) => {
56-
ctx.response.status(200).json({ hello: 'world!' })
45+
server.get('/', ({ response }) => {
46+
response
47+
.status(200)
48+
.send({ hello: 'world!', param: ctx.data.param })
5749
})
5850

59-
server.listen(4040, () => console.log('Server running!'))
51+
server.listen(1335, () => console.log('Server running!'))
6052
```
6153

6254
---

index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export * from './src/SecJS'
1+
export * from './src/Http'
22

3-
export * from './src/Context/Request/SecRequest'
4-
export * from './src/Context/Response/SecResponse'
3+
export * from './src/Contracts/Context/ContextContract'
4+
export * from './src/Contracts/Context/HandlerContract'
5+
export * from './src/Contracts/Context/RequestContract'
6+
export * from './src/Contracts/Context/ResponseContract'

0 commit comments

Comments
 (0)