# http-server-react-native-test

> HTTP server for React Native

Latest version **0.0.2** (published 2020-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install http-server-react-native-test
pnpm add http-server-react-native-test
yarn add http-server-react-native-test
bun add http-server-react-native-test
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-04-30 |
| First published | 2020-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nicolas Martinez |
| Maintainers | nmartinezb3 |
| Keywords | react-native |

## Links

- npm: https://www.npmjs.com/package/http-server-react-native-test
- Repository: https://github.com/nmartinezb3/react-native-http-server
- Homepage: https://github.com/nmartinezb3/react-native-http-server.git
- Issues: https://github.com/nmartinezb3/react-native-http-server/issues
- npm.io page: https://npm.io/package/http-server-react-native-test

## Recent versions

- 0.0.2 (latest) — 2020-04-30
- 0.0.1 — 2020-04-30

## README

# react-native-http-server
An HTTP server for react native based on https://github.com/swisspol/GCDWebServer

## Getting started

`$ npm install http-server-react-native --save`

### Mostly automatic installation

`$ react-native link http-server-react-native`

### Manual installation

#### iOS

1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-http-server` and add `RNHttpServer.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNHttpServer.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<

#### Android

Not supported yet

## Usage

```javascript
import React, { Component } from 'react';
import { HttpServer, Router }  from 'http-server-react-native';

class Server extends Component {

  componentDidMount() {
     const router = new Router('/path');
     router
      .get(data => {
        return { status: 200, data: { some: 'data' } };
      })
      .post(data => {
        return { status: 200, data: { some: 'data'} };
      })
      .put(data => {
        return { status: 200, data: { some: 'data'} };
      })
      .patch(data => {
        return { status: 200, data: { some: 'data'} };
      })
      .delete(data => {
        return { status: 200, data: { some: 'data'} };
      })

      this.server = new HTTPServer({ port: 8080 });
      this.server.registerRouter(router);
      this.server
        .start()
        .then(url => console.log(`Server running on ${url}`)
        .catch(err => console.error(err));
    }

    componentWillUnmount() {
      this.server.stop()
    }

    ...
}
;
```

---
_Source: https://npm.io/package/http-server-react-native-test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
