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

northwind-rest-api

v1.0.2

Published

Local REST API Exposing Northwind Database.

Downloads

29

Readme

northwind-rest-api

A local REST API for Northwind database, containing products, employees, suppliers, categories, authentication and more.

Installation:

npm i -g northwind-rest-api

(You must install it globally using the -g flag so the backend could be started via command-line.)

CLI Commands:

  • Run the REST API:
northwind  
  • Display help:
northwind --help 
  • Display version:
northwind --version

Existing Users:

  1. Admin User:
  1. Regular User:

Endpoints:

Products:

  • GET http://localhost:3030/api/products → Get all products.
  • GET http://localhost:3030/api/products/7 → Get product with id 7.
  • POST http://localhost:3030/api/products → Add a new product.
  • PUT http://localhost:3030/api/products/7 → Update product with id 7.
  • DELETE http://localhost:3030/api/products/7 → Delete product with id 7.
  • GET http://localhost:3030/api/products/images/01a5a6d5-6cc4-4e72-8f5d-e44efd3bc3d7.jpg → Get that product's image.
  • GET http://localhost:3030/api/products/top-three → Get top three products (must be logged-in).
  • GET http://localhost:3030/api/products/out-of-stock → Get out-of-stock products (must be admin).

Employees:

  • GET http://localhost:3030/api/employees → Get all employees.
  • GET http://localhost:3030/api/employees/7 → Get employee with id 7.
  • POST http://localhost:3030/api/employees → Add a new employee.
  • PUT http://localhost:3030/api/employees/7 → Update employee with id 7.
  • DELETE http://localhost:3030/api/employees/7 → Delete employee with id 7.
  • GET http://localhost:3030/api/employees/images/01a5f7d1-42e8-4f71-83c4-58e86751b272.jpg → Get that employee's image.

Suppliers:

  • GET http://localhost:3030/api/suppliers → Get all suppliers.
  • GET http://localhost:3030/api/suppliers/7 → Get supplier with id 7.
  • POST http://localhost:3030/api/suppliers → Add a new supplier.
  • PUT http://localhost:3030/api/suppliers/7 → Update supplier with id 7.
  • DELETE http://localhost:3030/api/suppliers/7 → Delete supplier with id 7.
  • GET http://localhost:3030/api/suppliers/images/01a57fe7-0f02-45e3-968b-65264020dd46.jpg → Get that supplier's image.

Categories:

  • GET http://localhost:3030/api/categories → Get all categories (must be logged-in).
  • GET http://localhost:3030/api/categories/7 → Get category with id 7 (must be logged-in).
  • POST http://localhost:3030/api/categories → Add a new category (must be logged-in).
  • PUT http://localhost:3030/api/categories/7 → Update category with id 7 (must be logged-in).
  • DELETE http://localhost:3030/api/categories/7 → Delete category with id 7 (must be admin).
  • GET http://localhost:3030/api/categories/images/01a1f85a-335e-4797-82b4-4c53d3aacb73.jpg → Get that category's image.

Contact Us:

  • POST http://localhost:3030/api/contact-us → Add a new contact-us message.
  • GET http://localhost:3030/api/contact-us → Get all contact-us messages (must be admin).

Auth:

  • POST http://localhost:3030/api/register → Register as a new user.
  • POST http://localhost:3030/api/login → Login as an existing user.
  • POST http://localhost:3030/api/refresh-token → Get back a new token (must be logged-in).

Slow Server Simulation:

For simulating a slow server you can precede each endpoint (besides image endpoints) with the word "delay". This will cause a 3 seconds delay for that route. This can help test how your frontend behaves when performing an http request to a slow server.

Examples:

  • GET http://localhost:3030/api/products → Gets all products without any delay.
  • GET http://localhost:3030/delay/api/products → Gets all products after a 3 seconds delay.
  • GET http://localhost:3030/api/employees/7 → Gets employee with id 7 without any delay.
  • GET http://localhost:3030/delay/api/employees/7 → Gets employee with id 7 after a 3 seconds delay.
  • POST http://localhost:3030/api/suppliers → Adds a new supplier without any delay.
  • POST http://localhost:3030/delay/api/suppliers → Adds a new supplier after a 3 seconds delay.

Entities:

User:

| Property | Description | |------------|-------------------| | id | User's ID | | firstName | User's first name | | lastName | User's last name | | email | User's email | | password | User's password | | role | User's role |

Product:

| Property | Description | |------------|--------------------------------| | id | Product's ID | | name | Product's name | | price | Product's price | | stock | Available stock of the product | | imageUrl | URL of the product's image |

Employee:

| Property | Description | |------------|-----------------------------| | id | Employee's ID | | firstName | Employee's first name | | lastName | Employee's last name | | title | Employee's job title | | country | Employee's country | | city | Employee's city | | birthDate | Employee's birth date | | imageUrl | URL of the employee's image |

Supplier:

| Property | Description | |------------|-----------------------------| | id | Supplier's ID | | company | Supplier's company name | | country | Supplier's country | | city | Supplier's city | | address | Supplier's address | | phone | Supplier's phone number | | imageUrl | URL of the supplier's image |

Category:

| Property | Description | |--------------|-----------------------------| | id | Category's ID | | name | Category's name | | description | Description of the category | | imageUrl | URL of the category's image |

Contact Us Message:

| Property | Description | |------------|-------------------------| | id | Contact's ID | | name | Contact's name | | email | Contact's email address | | phone | Contact's phone number | | message | Contact's message |