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

angularjs-coreservice

v1.0.0

Published

A base service for RESTFull API requests

Downloads

2

Readme

angularjs-coreservice

A base (model) class for services using Angular's Resource module

Installation

Install via Bower

bower install --save angularjs-coreservice

Install via NPM

npm install --save-dev angularjs-coreservice

Add the ApiHostname as a constant to your AngularJS Application. The Coreserver depends on this constant.

angular.module('MyApplication').constant('ApiHostname', 'http://localhost\\:9000/api');

Usage

find()

This call is needed when your API result is an object

Parameters:

  • query object|callback Enter the query string or recognizes this as successCallback when callback is given
  • successCallback callback This callback is called after data requested ended up with a HTTP 20x
  • errorCallback callback This callback is called after data requested ended up with another HTTP than 20x

Returns

$resource object

Find with object (Possible REST Example: [GET] http://url.com/app-variant/1.json?status=active)

AppVariants.find({id: 1, status: 'active'}) 

Find with object, successCallback

AppVariants.find({id: 1, status: 'active'}, function() { alert('done'); });

Find without object and successCallback (Possible REST Example: [GET] http://url.com/app-variant.json)

AppVariants.find(function() { alert('done'); });

findAll()

This call is needed when your API result is an array

Parameters:

  • query object|callback Enter the query string or recognizes this as successCallback when callback is given
  • successCallback callback This callback is called after data requested ended up with a HTTP 20x
  • errorCallback callback This callback is called after data requested ended up with another HTTP than 20x

Returns

$resource object

FindAll with object (Possible REST Example: [GET] http://url.com/app-variant.json?query=google)

AppVariants.findAll({query: 'google'}) 

Find with object, successCallback

AppVariants.findAll({query: 'google'}, function() { alert('done'); });

Find without object and successCallback (Possible REST Example: [GET] http://url.com/app-variant.json)

AppVariants.findAll(function() { alert('done'); });

findById()

This call is to do a quicker find call, when you only have an ID to GET

Parameters:

  • id string The identifier to request
  • successCallback callback This callback is called after data requested ended up with a HTTP 20x
  • errorCallback callback This callback is called after data requested ended up with another HTTP than 20x

Returns

$resource object

Find by ID without successCallback (Possible REST Example: [GET] http://url.com/app-variant/1.json)

AppVariants.findById(1)

Find by ID with successCallback (Possible REST Example: [GET] http://url.com/app-variant/1.json)

AppVariants.findById(1, function() { alert('done'); });

remove()

Do a DELETE call

Parameters:

  • query string|object|callback Enter the query string or recognizes this as successCallback when callback is given
  • successCallback callback This callback is called after data requested ended up with a HTTP 20x
  • errorCallback callback This callback is called after data requested ended up with another HTTP than 20x

Returns

$resource object

Delete by ID (Possible REST Example: [DELETE] http://url.com/app-variant/1.json)

AppVariants.remove(1)

Delete by ID with the callbacks (Possible REST Example: [DELETE] http://url.com/app-variant/1.json)

AppVariants.remove(1, function() { alert('done'); }, function() { alert('error') });

Delete by object with the callbacks (Possible REST Example: [DELETE] http://url.com/app-variant.json?status=active)

AppVariants.remove({status: 'active'}, function() { alert('done'); }, function() { alert('error') });

Delete all with the callbacks (Possible REST Example: [DELETE] http://url.com/app-variant.json)

AppVariants.remove(function() { alert('done'); }, function() { alert('error') });

delete()

Alias for remove()

create()

Do a POST call

Parameters:

  • query object Enter the query string with data you want to save
  • successCallback callback This callback is called after data requested ended up with a HTTP 20x
  • errorCallback callback This callback is called after data requested ended up with another HTTP than 20x

Returns

$resource object

Example request:

[POST] http://url.com/app-variant.json

[REQUEST BODY - application/json] 
{	
	name: 'Patrick',
	likes: 'github'
}

Post an object to the server

AppVariants.create({name: 'Patrick', likes: 'github'})

Post an object to the server with callbacks

AppVariants.create({name: 'Patrick', likes: 'github'}, function() { alert('done') }, function() { alert('error') })

update()

Do a PUT call

Parameters:

  • query object Enter the query string with data you want to save
  • successCallback callback This callback is called after data requested ended up with a HTTP 20x
  • errorCallback callback This callback is called after data requested ended up with another HTTP than 20x

Returns

$resource object

Example request:

[PUT] http://url.com/app-variant/1.json

[REQUEST BODY - application/json] 
{	
	name: 'Patrick',
	likes: 'github'
}

Post an object to the server

AppVariants.update({id: 1, name: 'Patrick', likes: 'github'})

Post an object to the server with callbacks

AppVariants.update({id: 1, name: 'Patrick', likes: 'github'}, function() { alert('done') }, function() { alert('error') })

save()

Alias for create() and update(). If the given query object has an ID key it will to the update() call, otherwise it will do a create() call

Parameters:

  • query object Enter the query string with data you want to save
  • successCallback callback This callback is called after data requested ended up with a HTTP 20x
  • errorCallback callback This callback is called after data requested ended up with another HTTP than 20x