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

nile-server

v1.0.11

Published

backend server for Nile

Downloads

7

Readme

Nile Project

NPM

You are an ambitious software developer that wants to start an online bookstore. You want to create a proof of concept, code named Nile Project, using your favorite frontend framework. nile-server provides a sample backend server to make it happen.

Impetus

With each frontend framework, such as React, mithril, and Vue, comes with the obligatory demo apps like TodoMVC. Sometimes it's a little difficult progressing from demo apps to the real world. The Nile Project is different. It comes with a fully functional backend that supports multiple authenticated users, with real time interactivity. You can write a product review that can be viewed by other users; when you make a purchase, it is stored in your shopping history and impacts the inventory; when you are viewing a product page, the background AJAX can check the real time inventory to see if it's low. nile-server handles all the backend API so you can write a good application that solves problems faced in the real world.

Usage

To run nile-server, run this in terminal:

npx nile-server

It pulls nile-server from npm and runs it on port 3570. Now you can use Postman to make request against it and start writing your SPA.

More Documentations

Architecture

nile-server tries to provide a simple yet complete API to allow development of a sample online bookstore. It stores the whole database in memory, so everything is wiped clean everytime the server is rebooted. A few JSON files are used to seed the database so it has some data to start with.

Data tables

Each table is an array of simple objects. Here are the tables:

  • Users - usernames, passwords and other preferences
  • Products - available products for sale and their prices
  • Hotitems - a list of ISBNs that should appear in front page
  • Reviews - user reviews of products
  • ShoppingHistory - list of previous purchases

APIs

nile-server only provides rudimentary APIs such as login/logout, simple filtering and CRUD operations. Here are the documented API endpoints:

  • GET /listhotitems - returns the list of products that should show up on front page
  • GET /listcategories - returns the list of product categories
  • POST /listproducts - returns the list of products. (POST body: filters)
  • POST /listreviews - returns the list of reviews. (POST body: filters)
  • POST /login - returns the login token if successful. (POST body: { username, password })
  • POST /profile - returns the user profile. (POST body: { token })
  • POST /purchase - purchase items. (POST body: { token, items, payment })
  • POST /supplyinventory - replenish inventory items. (POST body: { items })
  • POST /addbalance - add money to account. (POST body: { token, cardNo, balance }) cardNo always "5555666677778888"
  • POST /listshoppinghistory - returns the list of purchase history for the logged in user. (POST body: { token })
  • POST /addreview - add a review. (POST body: { token, isbn, rating, title, text })

API Examples: here are some examples of using the API.

Shopping cart

No API is provided for storing shopping carts. Store them in memory or web storage for now.

Security

nile-server simulates token based authentication, which is a versatile security model. However, the token is not encrypted, so it is only suitable for a sample app, and please don't put any sensitive data into this database. Here are the username/password that would work for the /login endpoint:

  • confucius / confucius2
  • newton / newton2
  • curie / curie2
  • mozart / mozart2
  • ada / ada2

Sample Implementation

nile-mithril is a fully functioning sample application that uses nile-server. Go to its GitHub Page to view its source.