Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handlerForSearch #86

Open
njsfield opened this issue Nov 14, 2016 · 0 comments
Open

handlerForSearch #86

njsfield opened this issue Nov 14, 2016 · 0 comments

Comments

@njsfield
Copy link

function handlerForSearch (request, response) {
  var searchTerm = request.url.split('?q=')[1];
  response.writeHead(200, {'content-type': 'text/plain'});
  response.end(JSON.stringify(runSmartMatch.smartMatch(searchTerm).slice(0, 10)));
}

Incase there are any issues of the formatting of queries that are passed into this function, use a module like 'url', where you can use .parse methods to access different segments of the url (an object for query holds key and value pairs for the query).
You could then easily have a few checks to see if query formatting is correct and provide a fail case if not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant