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

quick-rest-server

v1.0.5

Published

Generate simple REST API in a fastest way.

Downloads

8

Readme

quick-rest-server

Generate a simple REST API in less than 15 seconds.

Getting started

Install rest api

npm install quick-rest-server

Install nodemon for having hot reload

npm install nodemon

Basic Usage

import server from 'quick-rest-server'

server.config({ port: 3000 })

// Making type annotation for the data here is optional.
server.generateRoutes<{ id: number; name: string; price: number }>([
  {
    method: 'get',
    path: '/api/products',
    data: [
      { id: 1, name: 'Product 1', price: 500 },
      { id: 2, name: 'Product 2', price: 750 },
    ],
    delay: 2000,
  },
])

server.start()

After adding the code all you need to is type the command below in terminal(here it's assumed that we have that code in server.ts file)

npx nodemon server.ts

If you are going to use it in a ts project that is already exist, you may want to add a new folder and in that folder add an empty tsconfig.json file for preventing conflict might arise from having multiple tsconfig files.

mkdir mock-server
cd mock-server
touch server.ts
touch tsconfig.json

npx nodemon server.ts

Options

Config options(this options apply all routes if you don't override them in generateRoutes):
  --port            optional          Defaults to 5000
  --delay           optional          Defaults to 0

Route options:
  --method          required          Right now only accepts 'get'
  --path            required          Route path
  --data            required          Data to be stored
  --statusInfo      optional          Defaults to {status: 200, success: true, message?: Generic message changes according to success state }
  --delay           optional          Defaults to delay value specified in config