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

turbasen

v1.8.0

Published

Node.JS-client for Nasjonal Turbase

Downloads

27

Readme

turbasen.js

Build status NPM downloads NPM version Node version Dependency status

Node.JS-client for Nasjonal Turbase.

Requirements

  • Node.JS >= v4.0.0

Install

npm install turbasen --save

API

var turbasen = require('turbasen');

Object Types

| Data Type | API object | |------------|---------------------------| | Areas | turbasen.områder.… | | Photos | turbasen.bilder.… | | Places | turbasen.steder.… | | Trips | turbasen.turer.… | | Activities | turbasen.aktiviteter.… | | Groups | turbasen.grupper.… |

Status Codes

| Code | Explanation | |-------|--------------------------------| | 200 | Everything is OK | | 201 | Object created | | 204 | As 200 without any body | | 400 | Body is missing | | 400 | ObjectId is invalid | | 401 | Credentials are invalid | | 403 | Rate limit is exceeded | | 403 | Request was denied | | 404 | Resource was not found | | 404 | Object was not found | | 405 | HTTP method X is not allowed | | 422 | Body should be a JSON Hash | | 422 | Data validation failed | | 500 | Internal server error |

Configure

The following configurations are read from environment variables when this module is loaded:

  • NTB_API_KEY - API key for authenticate requests
  • NTB_API_ENV - API environment (default api, can be dev)
  • NTB_USER_AGENT - User Agent for API requests

These configurations can be overloaded using the turbasen.configure() like this:

turbasen.configure({
  API_KEY: 'my-api-key',
  API_ENV: 'dev',
  USER_AGENT: 'my-app/1.2.3'
});

List Objects

turbasen.områder(query, function(err, res, body) {
  if (err) { throw err; }

  console.log(body.count);
  console.log(body.documents);
});

Each Object

Asyncronously featch each object for a given query.

function each(item, next) {
  // do something async with the item
  next();
};

turbasen.områder.each(query, each, function(err) {
  // we are done!
});

Create Object

turbasen.bilder.post(object, function(err, res, body) {
  if (err) { throw err; }

  if (res.statusCode !== 201) {
    console.error(body.message);
    console.error(body.errors);
  } else {
    console.log(body);
  }
});

Get Object

turbasen.bilder.get(id, function(err, res, body) {
  if (err) { throw err; }

  if (res.statusCode !== 200) {
    console.error(body.message);
  } else {
    console.log(body);
  }
});

Delete Object

turbasen.bilder.delete(id, function(err, res, body) {
  if (err) { throw err; }

  if (res.statusCode !== 204) {
    console.error(body.message);
  } else {
    console.log('Document deleted successfully!');
  }
});

Put Object

turbasen.bilder.put(id, object, function(err, res, body) {
  if (err) { throw err; }

  if (res.statusCode !== 200) {
    console.log(body.errors);
  } else {
    console.warn(body.warnings);
    console.log(body.document);
  }
});

Patch Object

turbasen.bilder.patch(id, object, function(err, res, body) {
  if (err) { throw err; }

  if (res.statusCode !== 200) {
    console.log(body.errors);
  } else {
    console.warn(body.warnings);
    console.log(body.document);
  }
});

MIT License