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

osmose-request

v1.4.1

Published

Request the Osmose API from Javascript, with promises :)

Downloads

658

Readme

License: MIT GitHub release Build Status Coverage Status

Osmose Request

Request the Osmose API from Javascript, with promises :)

Installation

$ npm install osmose-request

Usage

import OsmoseRequest from 'osmose-request';

const osmose = new OsmoseRequest();

osmose.fetchErrors({ item: 8120 })
  .then(result => console.log(result));

In the previous example, the item option is one of the many Osmose options available and listed here: https://wiki.openstreetmap.org/wiki/Osmose/api/0.2#Settings

For now, the value of the options have the same shape as the real API options. It will be more JS friendly in the future.

So for example, if you want to limit the returned results to a specific location, you can add the bbox option like that:

import OsmoseRequest from 'osmose-request';

const osmose = new OsmoseRequest();

osmose.fetchErrors({ item: 8120, bbox: '1.123,-0.124,2.767,0.243' })
  .then(result => console.log(result));

Options

const osmose = new OsmoseRequest({
  language: 'fr',
  endpoint: 'https://...',
});

language

The Osmose API returns translated informations. That option lets you specify a language tag to be sent to the API in the Accept-Language HTTP header.

Read more informations about the format.

endpoint

The main Osmose instance is used by default but you can specify your own.

Methods

fetchErrors

Returns an errors list, you can provide some options to filter the result.

Read more about the available options.

osmose.fetchErrors({ item: 8120, status: 'open' })
  .then(result => console.log(result));

fetchError

Returns the informations about a specific error.

// With 123456 as an error ID
osmose.fetchError(123456)
  .then(result => console.log(result));

closeError

Closes the given error on Osmose server.

// With 123456 as an error ID
osmose.closeError(123456)
  .then(result => console.log(result)); // true if taken into account

falseError

Sets this error as a false positive on Osmose server.

// With 123456 as an error ID
osmose.falseError(123456)
  .then(result => console.log(result)); // true if taken into account

fetchSupportedCountries

Returns the list of the supported countries in the Osmose instance.

osmose.fetchSupportedCountries()
  .then(result => console.log(result));

fetchItemCategories

Return the list of the item categories with some details.

osmose.fetchItemCategories()
  .then(result => console.log(result));

fetchItems

Returns the list of the items configured in the Osmose instance and their translated name.

You can filter the returned translations to one language by specifying a two letters locale (eg: fr, en, ru).

// Without language filter
osmose.fetchItems()
  .then(result => console.log(result));
// With a language filter
osmose.fetchItems('fr')
  .then(result => console.log(result));

Contribute

To start contribute on this project, you can retrieve code using the following commands:

$ git clone [email protected]:osmlab/osmose-request.git
$ cd osmose-request
$ npm install
$ npm run watch

This project uses a specific work flow for branches:

  • master branch is dedicated to releases, managed by repo maintainers
  • develop branch is for currently developed version, managed by repo maintainers
  • feature/... branches are for all developers, working on a particular feature

Pull requests are welcome, as the project is fully open-source. If you want to work on new features, please create a branch named feature/yourFeatureName. When work is done, open a pull request to merge your branch on develop branch. The code will be reviewed by one or several developers before being merged, in order to keep a good code quality.

Make a release

$ git checkout develop
$ git pull origin develop
$ npm version patch -m "release: %s"
$ npm publish
$ git checkout master
$ git pull origin master
$ git merge develop
$ git push origin master

npm version tests the code, builds it and updates the doc. Then it upgrades the package version number according to the used keyword (patch, minor or major) and commits the modifications in Git (with a proper version tag). Finally, it pushes it to repository with the tag.