Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,32 @@ The intention behind this repository is to always maintain a `Http` package to a

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

## WARN 🛑⚠️

> This project is under `development` do not use it until releases v1.0.0.

## Installation

> To use the high potential from @secjs/http you need to install first this packages from SecJS,
> it keeps as dev dependency because one day @secjs/core will install everything once.

```bash
npm install @secjs/contracts @secjs/utils
```

```bash
npm install @secjs/http
```

## Usage

### SecJS
### Http

> Use SecJS to create the Http server and map all your routes with handlers
> Use Http class to create the http server and map all your routes

```ts
import { SecJS } from '@secjs/http'
import { SecContextContract } from '@secjs/contracts'
import { Http, ContextContract } from '@secjs/http'

const server = new Http()

const server = new SecJS()
server.use(ctx => ctx.data.param = 'param')

server.get('/', (ctx: SecContextContract) => {
ctx.response.status(200).json({ hello: 'world!' })
server.get('/', ({ response }) => {
response
.status(200)
.send({ hello: 'world!', param: ctx.data.param })
})

server.listen(4040, () => console.log('Server running!'))
server.listen(1335, () => console.log('Server running!'))
```

---
Expand Down
8 changes: 5 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './src/SecJS'
export * from './src/Http'

export * from './src/Context/Request/SecRequest'
export * from './src/Context/Response/SecResponse'
export * from './src/Contracts/Context/ContextContract'
export * from './src/Contracts/Context/HandlerContract'
export * from './src/Contracts/Context/RequestContract'
export * from './src/Contracts/Context/ResponseContract'
Loading