{"_id":"@altrdpdgm/cors","_rev":"1-4411a25a1eaea38080e42db00a6a3bd0","name":"@altrdpdgm/cors","description":"Tiny Express middleware for facilitating CORS.","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@altrdpdgm/cors","version":"2.0.0","description":"Tiny Express middleware for facilitating CORS.","main":"index.js","scripts":{"test":"mocha test/index.js"},"author":{"name":"Sean T Taylor"},"license":"ISC","devDependencies":{"mocha":"^5.0.0"},"gitHead":"2b4e9dba4a8ae187e79205b71b2e6b9a51635746","_id":"@altrdpdgm/cors@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.1","_npmUser":{"name":"altrdpdgm","email":"altrdpdgm@gmail.com"},"dist":{"integrity":"sha512-5NoGrquQLczNXMG/T5OBnhbQUQ+6W5IzOLDLtsykJexUtH8Z4PAbsYmNmv7W9kAtZxsEf7OKsSu1cYKOD0Vi+A==","shasum":"18e6d374372b04175fdb48a38bbf56abeb2bedc1","tarball":"https://registry.npmjs.org/@altrdpdgm/cors/-/cors-2.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDu1o2r/C2mYJeogwp0C3Gcp6TicU3GCwreggRV1gS/hQIhAKZHqOvYgng53Gb4WxUM1xBHcQvMwVMXZyhL83ZspiGJ"}]},"maintainers":[{"name":"altrdpdgm","email":"altrdpdgm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cors-2.0.0.tgz_1517716493578_0.7886634818278253"}}},"readme":"# @altrdpdgm/cors\nTiny Express middleware for facilitating CORS requests.\n\n## API Reference\n\n| Method | Description |\n|---| ---|\n|setOriginList | takes an Array of origins to allow CORS requests from. |\n|getOriginList | returns the current list of allowed origins.|\n|handleCORS | Express middleware function. Handles pre-flight requests; sets user-defined or default response headers. |\n\n\n## Implementation Reference\n\n| Function | Description |\n|---|---|\n|validateOrigin | Determines whether the origin making the request is allowed by checking for the origin in the internal __originList via `Array.prototype.includes`. |\n|isPreFlight | Determines whether a request is a pre-flight request; checks for `OPTIONS` method, `Access-Control-Request-Method` header and the origin of the request. |\n\n## Default Configuration\n\nIf no user-defined response headers are found in the `headers` property of the options object (detailed below) when the @altrdpdgm/cors module is instantiated, the following response headers will be set automatically:\n\n\n    {\n    \"Access-Control-Allow-Origin\": validateOrigin(req.headers[\"origin\"]),\n    \"Access-Control-Allow-Headers\": \"Content-Type, Authorization\",\n    \"Access-Control-Allow-Methods\": \"DELETE\"\n    }\n    \nThe response header object takes any options that can be set on the response using the Express [res.set method](http://expressjs.com/en/4x/api.html#res.set)\n \n## Installation \n`$npm install @altrdpdgm/cors`\n\n    \n## Example Instantiation\n```javascript    \nconst express = require(\"express\");\nconst app = express();\nconst CORSModule = require(\"@altrdpdgm/altrd-cors\")({options}) //<= set custom response headers in a configuration object on a `headers` property.\nCORSModule.setOriginList([\"http://localhost:3000\", \"http://10.0.18.108\", \"http://0.0.0.0\"]);\n\n//Configure the Express application to use the CORSModule on all incoming requests.\napp.use(CORSModule.handleCORS)\n```\n\n    \n\n\n\n\n\n\n\n\n","maintainers":[{"name":"altrdpdgm","email":"altrdpdgm@gmail.com"}],"time":{"modified":"2022-04-04T13:40:38.014Z","created":"2018-02-04T03:54:54.433Z","2.0.0":"2018-02-04T03:54:54.433Z"},"author":{"name":"Sean T Taylor"},"license":"ISC","readmeFilename":"README.md"}