# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cod3vils-organization.gitbook.io/michaelnji/small-libraries/nexus-req.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
