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

bl-connect

v0.4.3

Published

A connecter module for talking to the **bl-api** from a Angular application.

Downloads

104

Readme

bl-connect

A connecter module for talking to the bl-api from a Angular application.

Before you begin

This library requires

Angular 5+

You can get Angular at: https://angular.io/

bl-model

The bl-model package is a peerDependency to this project.

To install bl-model into your own Angular project. Do the following in a Terminal:

cd path/to/your/own/angular-project
npm install bl-model 

Installation

To install bl-connect to your own Angular project. Do the following in a Terminal:

cd path/to/your/own/angular-project
npm install bl-connect

Important to remember!

To get and post real data you need to have a running instance of the bl-api

How to use this library

To import this library in your module:

imports: [..., BlConnectModule]

Now you can use the services in your components. The services are explained below.

ItemService

to import this service:

import {ItemService} from 'bl-connect';

the methods you can use :

get(query?: string): Promise<Item[]>
getById(id: string): Promise<Item>

BranchService

to import this service:

import {BranchService} from 'bl-connect';

the methods you can use:

get(query?: string): Promise<Branch[]>
getById(id: string): Promise<Branch>

OpeningHourService

to import this service:

import {OpeningHourService} from 'bl-connect';

the methods you can use:

getById(id: string): Promise<OpeningHour>

CustomerItemService

to import this service:

import {CustomerItemService} from 'bl-connect';

the methods you can use:

getById(id: string): Promise<CustomerItemService>
add(customerItem: CustomerItem): Promise<CustomerItem>
update(id: string, data: any): Promise<CustomerItem>

OrderService

to import this service:

import {OrderService} from 'bl-connect';

the methods you can use:

getById(id: string): Promise<Order>
add(order: Order): Promise<Order>
update(id: string, data: any): Promise<Order>

Error handling

When you use a service and that service rejects with an error you get a object of the type BlApiError. The error classes are provided by bl-model and are therefore easy to understand. We have four different types of BlApiErrors that bl-connect services throws, under is a description for all of them:

BlApiLoginRequiredError

Used when the request requires a login and no valid access token is found. The user needs to login to get this document.

BlApiPermissionDeniedError

Used when the request is valid, but the user lacks the given permission for this endpoint.

BlApiNotFoundError

Used when the document asked for is not found.

BlApiError

This is error is thrown if none of the above errors is applicable.

Example of error handling:


myMethod() {
	
	this.itemService.get().then((items: Item[]) => {
		
		//do something	
		
	}).catch((apiErr: BlApiError) => {
		
		if (apiErr instanceof BlApiLoginRequiredError) {
			// do something with login error 
		}
        
		if (apiErr instanceof BlApiPermissionDeniedError) {
			//do something with permission denied error 
		}
        
		if (apiErr instanceof BlApiNotFoundError) {
			//do something with document not found error 
		}
        
		if (apiErr instanceof BlApiError) {
			// do something with the general error
		}
	}
}