{"id":17983465,"url":"https://github.com/techjacker/express-validate-requests","last_synced_at":"2025-04-04T02:12:56.387Z","repository":{"id":141451320,"uuid":"9402012","full_name":"techjacker/express-validate-requests","owner":"techjacker","description":"validate and sanatize requests in express.js","archived":false,"fork":false,"pushed_at":"2013-06-05T12:02:36.000Z","size":144,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T01:03:57.742Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techjacker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-12T19:26:46.000Z","updated_at":"2014-05-11T14:31:17.000Z","dependencies_parsed_at":"2023-03-12T04:56:25.785Z","dependency_job_id":null,"html_url":"https://github.com/techjacker/express-validate-requests","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fexpress-validate-requests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fexpress-validate-requests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fexpress-validate-requests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fexpress-validate-requests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techjacker","download_url":"https://codeload.github.com/techjacker/express-validate-requests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103254,"owners_count":20884024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T18:17:19.645Z","updated_at":"2025-04-04T02:12:56.367Z","avatar_url":"https://github.com/techjacker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express Validate Requests\n\n[![Build Status](https://secure.travis-ci.org/techjacker/express-validate-requests.png)](http://travis-ci.org/techjacker/express-validate-requests)\n\n## QuickStart\n#### The following MIDDLEWARE (app.use(fn)) methods are included:\n- sanitizeRequest(req, res, next)\n- allowJustXHR(req, res, next)\n- allowJustJsonRequests(req, res, next)\n- allowXOrigin(req, res, next)\n\nIf the validation fails then an next(error) will be called. You should set up an error catcher as your last piece of middleware as a catchall for any errors.\n\n#### The following helper fns are included:\n- checkGotAllParams(params:{@Object}, requiredParamsKeys:{@Array})\n\n## Full Example\n\n```JavaScript\nvar express    \t= require('express'),\n    app        \t= express(),\n    valExpress \t= require('express-validate-requests'),\n    middle \t\t= valExpress.middleware,\n    helpers\t\t= valExpress.helpers,\n\tallowedHosts = [\"api.domainx.com\", \"www.domainx.com\"],\n\tallowedOrigins = [\"http://domainx.com\", \"http://www.domainx.com\"];\n\napp.configure(function() {\n\tapp.use(middle.allowJustXHR);\n\tapp.use(middle.onlyAllowJsonRequests);\n\tapp.use(middle.sanitizeRequest);\n\n\t// middle.setAllowCrossOrigin returns fn(req, res, next)\n\tapp.use(middle.setAllowCrossOrigin(allowedHosts, allowedOrigins));\n});\n\napp.get('/someroute', function (req,res,next) {\n\tvar requiredParamsKeys = [\"paramOneKey\", \"paramTwoKey\"];\n\tif (!helpers.checkGotAllParams(req.query, requiredParamsKeys)) {\n\t\tnext(new Error('invalid params'));\n\t} else {\n\t\tnext();\n\t}\n});\n\n//... error catcher at very bottom\napp.configure('development', function() {\n    app.use(express.errorHandler()); // built-in express error handler\n});\n\n// listen once configured everything\nhttp.createServer(app).listen(app.get('port'), function() {\n\tconsole.log(\"Express server listening on port: \" + app.get('port'));\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fexpress-validate-requests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechjacker%2Fexpress-validate-requests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fexpress-validate-requests/lists"}