Skip to content

handlerForSearch #86

Description

@njsfield
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions