> For the complete documentation index, see [llms.txt](https://cod3vils-organization.gitbook.io/michaelnji/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cod3vils-organization.gitbook.io/michaelnji/small-libraries/nexus-req.md).

# nexus-req

## Introduction

nexus-req is a small library built to normalize server responses within full stack applications. It can be used in frameworks that do not provide a standard way of returning structured responses from server-side, such as Nuxtjs.

### Installation

**Bun**

```bash
bun i nexus-req
```

**NPM**

```bash
npm i nexus-req
```

### Usage.

#### sendServerResponse

Returns a structured response object that can be returned as server response.

{% code overflow="wrap" %}

```typescript
import { sendServerResponse } from 'nexus-req';
import type { ErrorCodes } from 'nexus-req';

const response = sendServerResponse<ErrorCodes>(400, 'This user is unauthorized to access this information.');
console.log(response) 

/** 
    returns {
    ok: false
    status: 400
    message: 'This user is unauthorized to access this information.'
    data: null
    }
**/


```

{% endcode %}
