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

fast-furniture-util

v1.0.95

Published

This fast furniture node package constians mongoose driver connection, repositories and models

Downloads

27

Readme

README

This fast furniture node package constians mongoose driver connection, repositories and models

Install

npm i fast-furniture-util

Usage

import { AzureFunction, Context, HttpRequest } from '@azure/functions'
import FastFurniture from 'fast-furniture-util'
import errorHandler from '../shared/error'
const { connect, SupplierRepository } = FastFurniture

const httpTrigger: AzureFunction = async function (
  context: Context,
  req: HttpRequest
): Promise<void> {
  await connect(process.env.CosmosDBConnectionString) // Set the Cosmos DB Connection String
    .then(async (resp) => {
      let supplier_id = req.query.supplier_id
      const supplierRepo = new SupplierRepository()
      const notes = await supplierRepo.getNotes(supplier_id)

      context.res = {
        body: { notes },
      }

      return context.done()
    })
    .catch((error) => {
      errorHandler(400, error, context)
    })
}

export default httpTrigger

Repositories

1. SupplierRepository

2. ProductRepository

2. NoteRepository

Functions of each Repositories

SupplierRepository

Save Supplier

const supplierRepo = new SupplierRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

let newSupplier = await supplierRepo.save(payload)

Delete Supplier

const supplierRepo = new SupplierRepository()
const supplierModel = await supplierRepo.delete(_id)

Get All Supplier

const supplierRepo = new SupplierRepository()
const suppliers = await supplierRepo.findAll()

Update Supplier

const supplierRepo = new SupplierRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

const supplier = await supplierRepo.update(_id, payload)

Create Note

const supplierRepo = new SupplierRepository()

const payload = {
  title: title,
  note: note,
  user: user,
}

let supplier = await supplierRepo.addNote(supplier_id, payload)

ProductRepository

Save Product

const productRepo = new ProductRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

let newProduct = await productRepo.save(payload)

Delete Product

const productRepo = new ProductRepository()
const product = await productRepo.delete(_id)

Get All Product

const productRepo = new ProductRepository()
const product = await productRepo.findAll()

Update Product

const productRepo = new ProductRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

const product = await productRepo.update(_id, payload)

NoteRepository

Delete Note

const noteRepo = new NoteRepository()
let note = await noteRepo.remove(_id)

Get Notes

const supplierRepo = new SupplierRepository()
const notes = await supplierRepo.getNotes(supplier_id)

Update Note

const noteRepo = new NoteRepository()

const payload = {
  supplier_id: supplier_id,
  title: title,
  note: note,
  user: user,
}

let updatedNote = await noteRepo.update(_id, payload)