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

@ashish_agarwal/online-ordering

v1.0.17

Published

apis to be consumed for ecommerce implementation

Downloads

3

Readme

E-commerce Abstraction

Package Conception

This npm module has been created with a motive to provide abstraction to the apis used from various API layers in the CS ecommerce module. This module can be imported to projects as a package and the API's can be used to support solutions in e-commerce

Features

  • Easy to use API to support solution in Elastic
  • Perform operations to SFDC and Elastic API directly

Package Usage

Installation

This package is only accessible through CloudSense’s private NPM repository.

npm i @ashish_agarwal/online-ordering

IMP: create registry file (.npmrc) on root folder with the registry key from cs

Dependencies

Install express and dotenv

npm i express
npm i dotenv

API Specification

Details of all the API's are mentioned in the API Specifications which can be accessed from

Here is a sequence diagram to explain how our API's works and how it can be implemented end to end for each use case scenario

alt text

NPM Module Setup

Implementing cache

This project includes an object for caching implementation which can be overriden to apply custom cache implementation. This is embeded into the abstract api calls to get and set the data to the cache

the below code shows how to add custom cache implementaiton and inject into the npm module

const api = require('@ashish_agarwal/online-ordering');

api.caching.cachingObj.prototype.getCacheData = cachingImp.getCacheData
api.caching.cachingObj.prototype.setCacheData = cachingImp.setCacheData

Using API's

1.) Let's import the package and call it as api wherever the API needs to be called.

// Importing the package as api
const api = require('@ashish_agarwal/online-ordering');

2.) To perform operation on EAPI and SFDC, authentication details needs to be shared. Create a .env file and add the below details

CLIENT_ID = //shared by cs security team
CLIENT_SECRET = //shared by cs security team
target_Heroku_instance_domain = //shared by cs security team
SFDC_URL = //your salesforce domain url
SFDC_USERNAME = //your sfdc user name for fetching data
SFDC_PASSWORD = //your sfdc user name for fetching data
SFDC_TOKEN = //sfdc token
dispatcherHost = //shared by cs security team
orgId = //salesforce org id
private_key = //private key for the certificate shared between sfdc instance and heroku instance
rsa_pvt_key = //rsa private key for the certificate shared between sfdc instance and heroku instance
catalogueId = //catalogue salesforce id published to the heroku

3.) Let us see some scenarios with implementation examples

a.) List solution - Assume a scenario where all the solution templates needs to be fetched from the org.

  • Assuming there is an app cache module in place which caches solution templates request. If the app cache already stores the details of the org then the soution templates can be fetched from the app cache without requesting the module.
  • Once the solution templates are listed, select a solution component which can be used to add offers and products

example :

const express = require('express');
require('dotenv').config();
const api = require('@ashish_agarwal/online-ordering');

app.use(express.json());

app.use('/api/getsolutiontemplates',(req, res, next)=>{
  api.caching.cachingObj.prototype.key = 'solutionTemplates' //defining key to store the data into cache
  next()
}, api.solutionTemplates)