1.0.1 • Published 2 years ago

key-value-extractor v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Logo

key&value-Extractor

This module include functino that get url as argoman and check validation of url, if url is valid send it to 2end function and return key and value as object and if url be invalid or with out query parameter return empty object.

Usage/Examples

make server.js file and copy following code into that then run server and test the url.

const http = require("http");
const queApi = require('./queKeyValues.js')

const port = 3000; //enter your port
const hostname = "localhost"; 
//run server
const server = http.createServer((req, res) => {
  let resultOfKeyValue = JSON.stringify(queApi.apiKeyValueOfQuery(req.url)) ;
  res.setHeader("Content-Type", "application/json");
  res.end(resultOfKeyValue);
}).listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/ `);
});

you can test all kind of url and check the response

   http://localhost:3000/test1/test2
   http://localhost:3000/test1/test2?
   http://localhost:3000/test1/test2?id
   http://localhost:3000/test1/test2?id=1
   http://localhost:3000/test1/test2?id=1&
   http://localhost:3000/test1/test2?id=1&hello=

and blablabla

Installation

This is Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.10 or higher is required.

If this is a brand new project, make sure to create a package.json first with the npm init command.

Installation is done using the npm install command:

  $ npm i key-value-extractor

Authors

Features

  • Check validating of url by reqex
  • Extract all query parameter of url