npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zer0cheros/simple-react-server

v1.1.8

Published

a way to test your react framework with a really easy and fast api

Downloads

41

Readme

Zer0cheros

simple-react-server

A method for testing your React application against a simple and minimal backend API server. The server is a mix of express package and knex package. Simplifying coding for a more enjoyable experience.

  • Don´t use in production!!
  • Only for development!!

When you install the package, it automatically creates a 'server.ts' file in your '/src' folder.

Server-side

import Server from '@zer0cheros/simple-react-server'

const server = new Server(8080)

//Config DB with you own credentials
server.connect('db', {client: "mysql", host: '127.0.0.1', port: 3306, user: 'root', password: 'password'})

// When no specific request is made, a default JSON response will be presented.
server.Get('/')

//A query to retrieve all data from the 'users' table in the database
server.Get('/users', true).DB('users')

// A query to retrieve data from the 'users' table in the database, with a specific id
server.Get('/users', false, true).DB('users').ID(4) 

//Starts application
server.start()

Client

//simple example of using client and server
import { useState, useEffect } from 'react'
import Client from '@zer0cheros/simple-react-server/client'


function App() {
  const [users, setUsers] = useState([]) //your types here
  const client = new Client('http://localhost:8080')
  useEffect(()=>{
    client.Get('/users').then((res)=>{
      setUsers(res) 
    })
  },[])
  return (
    <div>
      {users.map((user:any)=>(
        <div key={user.id}>
          <h1>{user.name}</h1>
          <h2>{user.email}</h2>
        </div>
      )
      )}
    </div>
  )
}

export default App

Installation

$ npm install @zer0cheros/simple-react-server

Recommended for more optimized development.

  1. Installing script for setting up automation tools.
$ npm install npm-run-all nodemon -g
  1. Add this to your package.json
"scripts": {
  "server-build": "tsc ./src/server.ts && move src\\server.js src\\server.cjs",
  "server-run": "nodemon ./src/server.cjs",
  "server-start": "npm-run-all --parallel server-build server-run"
}

Features

  • Easy setup
  • Less code
  • Workning upon express

People

The teacher behind is Christian

License

MIT