Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

anye

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anye

Server-agnostic named URL builder for node.js

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-25%
Maintainers
3
Weekly downloads
 
Created
Source

anyè

NPM version Build Status Dependency Status Downloads counter

Server-agnostic named URL builder for node.js


Getting started

Install the module with: npm install anye

Usage

Require module.

var Anye = require( "anye" );

Store/set an URL

Signature
Anye.set( sName, sURL );
Arguments
  • sName is the key to store the URL
  • sURL is the URL to store. It can have named-parameters beginning by :, like in /url/:id.

Note: the set method returns the stored URL, so you can use it directly in your route definition like in express: app.post( Anye.set( "name", "/url/:id" ), routeHandler );

Example
Anye.set( "name", "/url/:id" ); // will returns "/url/:id"

Retrieve/get/build an URL

Signature
Anye.get( sName, oParams, bEncode )
Arguments
  • sName is the key of the URL in the store.
  • oParams is an hash of parameters for the URL, replacing the :variable in the stored URL. All the additonal parameters will be added to the query string of the URL.
  • bEncode is a flag to ensure the returned URL is URL-encoded. false by default.

Note: if a parameter of the URL is not given, anyè will throws.

Example
Anye.get( "name", { id: 2 } ); // will returns "/url/2"
Anye.get( "name", { id: "bar^" }, true ); // will returns "/url/bar%5E"
Anye.get( "name", { id: 2, foo: "bar", bar: "baz" } ); // will returns "/url/2?foo=bar&bar=baz"

Clear the store

Signature
Anye.clear()
Example
Anye.get( "name", { id: 2 } ); // will returns "/url/2"
Anye.clear();
Anye.get( "name", { id: 2 } ); // throws Error

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

2014-10-06: version 0.2.0, add query-string population with additional parameters. 2014-10-05: version 0.1.0, initial release.

License

Copyright (c) 2014 Leny for KRKN
Licensed under the MIT license.

Keywords

FAQs

Package last updated on 05 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc