Repository: jshttp/methods Branch: master Commit: f89e491ab3f2 Files: 14 Total size: 20.5 KB Directory structure: gitextract_52q28y5z/ ├── .eslintignore ├── .eslintrc.yml ├── .github/ │ └── workflows/ │ ├── ci.yml │ ├── codeql.yml │ └── scorecard.yml ├── .gitignore ├── HISTORY.md ├── LICENSE ├── README.md ├── index.js ├── package.json └── test/ ├── .eslintrc.yml ├── browserify.js └── methods.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintignore ================================================ coverage node_modules ================================================ FILE: .eslintrc.yml ================================================ root: true extends: standard ================================================ FILE: .github/workflows/ci.yml ================================================ name: ci on: - pull_request - push permissions: contents: read jobs: test: permissions: checks: write # for coverallsapp/github-action to create new checks contents: read # for actions/checkout to fetch code runs-on: ubuntu-latest strategy: matrix: name: - Node.js 0.6 - Node.js 0.8 - Node.js 0.10 - Node.js 0.12 - io.js 1.x - io.js 2.x - io.js 3.x - Node.js 4.x - Node.js 5.x - Node.js 6.x - Node.js 7.x - Node.js 8.x - Node.js 9.x - Node.js 10.x - Node.js 11.x - Node.js 12.x - Node.js 13.x - Node.js 14.x - Node.js 15.x - Node.js 16.x - Node.js 17.x - Node.js 18.x - Node.js 19.x - Node.js 20.x - Node.js 21.x include: - name: Node.js 0.6 node-version: "0.6" npm-i: mocha@1.21.5 npm-rm: nyc - name: Node.js 0.8 node-version: "0.8" npm-i: mocha@2.5.3 npm-rm: nyc - name: Node.js 0.10 node-version: "0.10" npm-i: mocha@3.5.3 nyc@10.3.2 - name: Node.js 0.12 node-version: "0.12" npm-i: mocha@3.5.3 nyc@10.3.2 - name: io.js 1.x node-version: "1.8" npm-i: mocha@3.5.3 nyc@10.3.2 - name: io.js 2.x node-version: "2.5" npm-i: mocha@3.5.3 nyc@10.3.2 - name: io.js 3.x node-version: "3.3" npm-i: mocha@3.5.3 nyc@10.3.2 - name: Node.js 4.x node-version: "4.9" npm-i: mocha@5.2.0 nyc@11.9.0 - name: Node.js 5.x node-version: "5.12" npm-i: mocha@5.2.0 nyc@11.9.0 - name: Node.js 6.x node-version: "6.17" npm-i: mocha@6.2.2 nyc@14.1.1 - name: Node.js 7.x node-version: "7.10" npm-i: mocha@6.2.2 nyc@14.1.1 - name: Node.js 8.x node-version: "8.17" npm-i: mocha@7.1.2 nyc@14.1.1 - name: Node.js 9.x node-version: "9.11" npm-i: mocha@7.1.2 nyc@14.1.1 - name: Node.js 10.x node-version: "10.24" npm-i: mocha@8.4.0 - name: Node.js 11.x node-version: "11.15" npm-i: mocha@8.4.0 - name: Node.js 12.x node-version: "12.22" npm-i: mocha@9.2.2 - name: Node.js 13.x node-version: "13.14" npm-i: mocha@9.2.2 - name: Node.js 14.x node-version: "14.21" - name: Node.js 15.x node-version: "15.14" - name: Node.js 16.x node-version: "16.20" - name: Node.js 17.x node-version: "17.9" - name: Node.js 18.x node-version: "18.18" - name: Node.js 19.x node-version: "19.9" - name: Node.js 20.x node-version: "20.9" - name: Node.js 21.x node-version: "21.1" steps: - uses: actions/checkout@v3 - name: Install Node.js ${{ matrix.node-version }} shell: bash -eo pipefail -l {0} run: | if [[ "${{ matrix.node-version }}" == 0.6* ]]; then sudo sh -c 'echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic universe" >> /etc/apt/sources.list' sudo sh -c 'echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list' sudo apt-get update sudo apt-get install g++-4.8 gcc-4.8 libssl1.0-dev python2 python-is-python2 export CC=/usr/bin/gcc-4.8 export CXX=/usr/bin/g++-4.8 fi nvm install --default ${{ matrix.node-version }} if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then nvm install --alias=npm 0.10 nvm use ${{ matrix.node-version }} if [[ "$(npm -v)" == 1.1.* ]]; then nvm exec npm npm install -g npm@1.1 ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" else sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" fi npm config set strict-ssl false fi dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" - name: Configure npm run: | if [[ "$(npm config get package-lock)" == "true" ]]; then npm config set package-lock false else npm config set shrinkwrap false fi - name: Remove npm module(s) ${{ matrix.npm-rm }} run: npm rm --silent --save-dev ${{ matrix.npm-rm }} if: matrix.npm-rm != '' - name: Install npm module(s) ${{ matrix.npm-i }} run: npm install --save-dev ${{ matrix.npm-i }} if: matrix.npm-i != '' - name: Setup Node.js version-specific dependencies shell: bash run: | # eslint for linting # - remove on Node.js < 12 if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ grep -E '^eslint(-|$)' | \ sort -r | \ xargs -n1 npm rm --silent --save-dev fi - name: Install Node.js dependencies run: npm install - name: Install browserify run: | if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -ge 1 ]]; then npm install --save-dev browserify@16 fi - name: List environment id: list_env shell: bash run: | echo "node@$(node -v)" echo "npm@$(npm -v)" npm -s ls ||: (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" - name: Run tests shell: bash run: | if npm -ps ls nyc | grep -q nyc; then npm run test-ci else npm test fi - name: Lint code if: steps.list_env.outputs.eslint != '' run: npm run lint - name: Collect code coverage uses: coverallsapp/github-action@master if: steps.list_env.outputs.nyc != '' with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.test_number }} parallel: true coverage: permissions: checks: write # for coverallsapp/github-action to create new checks needs: test runs-on: ubuntu-latest steps: - name: Upload code coverage uses: coverallsapp/github-action@master with: github-token: ${{ secrets.github_token }} parallel-finished: true ================================================ FILE: .github/workflows/codeql.yml ================================================ # For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: ["master"] pull_request: # The branches below must be a subset of the branches above branches: ["master"] schedule: - cron: "0 0 * * 1" permissions: contents: read jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: ["javascript"] # CodeQL supports [ $supported-codeql-languages ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - name: Checkout repository uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v4.32.4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v4.32.4 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | # echo "Run, Build Application using script" # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v4.32.4 with: category: "/language:${{matrix.language}}" ================================================ FILE: .github/workflows/scorecard.yml ================================================ # This workflow uses actions that are not certified by GitHub. They are provided # by a third-party and are governed by separate terms of service, privacy # policy, and support documentation. name: Scorecard supply-chain security on: # For Branch-Protection check. Only the default branch is supported. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection branch_protection_rule: # To guarantee Maintained check is occasionally updated. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained schedule: - cron: '16 21 * * 1' push: branches: [ "master" ] # Declare default permissions as read only. permissions: read-all jobs: analysis: name: Scorecard analysis runs-on: ubuntu-latest permissions: # Needed to upload the results to code-scanning dashboard. security-events: write # Needed to publish results and get a badge (see publish_results below). id-token: write # Uncomment the permissions below if installing in a private repository. # contents: read # actions: read steps: - name: "Checkout code" uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - name: "Run analysis" uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6 with: results_file: results.sarif results_format: sarif # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: # - you want to enable the Branch-Protection check on a *public* repository, or # - you are installing Scorecard on a *private* repository # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. # repo_token: ${{ secrets.SCORECARD_TOKEN }} # Public repositories: # - Publish results to OpenSSF REST API for easy access by consumers # - Allows the repository to include the Scorecard badge. # - See https://github.com/ossf/scorecard-action#publishing-results. # For private repositories: # - `publish_results` will always be set to `false`, regardless # of the value entered here. publish_results: true # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: name: SARIF file path: results.sarif retention-days: 5 # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" uses: github/codeql-action/upload-sarif@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3.32.4 with: sarif_file: results.sarif ================================================ FILE: .gitignore ================================================ .DS_Store* *.log *.gz node_modules coverage cache package-lock.json ================================================ FILE: HISTORY.md ================================================ 1.1.2 / 2016-01-17 ================== * perf: enable strict mode 1.1.1 / 2014-12-30 ================== * Improve `browserify` support 1.1.0 / 2014-07-05 ================== * Add `CONNECT` method 1.0.1 / 2014-06-02 ================== * Fix module to work with harmony transform 1.0.0 / 2014-05-08 ================== * Add `PURGE` method 0.1.0 / 2013-10-28 ================== * Add `http.METHODS` support ================================================ FILE: LICENSE ================================================ (The MIT License) Copyright (c) 2013-2014 TJ Holowaychuk Copyright (c) 2015-2016 Douglas Christopher Wilson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Methods [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Node.js Version][node-image]][node-url] [![Build Status][ci-image]][ci-url] [![Coverage Status][coveralls-image]][coveralls-url] HTTP verbs that Node.js core's HTTP parser supports. This module provides an export that is just like `http.METHODS` from Node.js core, with the following differences: * All method names are lower-cased. * Contains a fallback list of methods for Node.js versions that do not have a `http.METHODS` export (0.10 and lower). * Provides the fallback list when using tools like `browserify` without pulling in the `http` shim module. ## Install This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/). Installation is done using the [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): ```sh $ npm install methods ``` ## API ```js var methods = require('methods') ``` ### methods This is an array of lower-cased method names that Node.js supports. If Node.js provides the `http.METHODS` export, then this is the same array lower-cased, otherwise it is a snapshot of the verbs from Node.js 0.10. ## License [MIT](LICENSE) [ci-image]: https://badgen.net/github/checks/jshttp/methods/master?label=ci [ci-url]: https://github.com/jshttp/methods/actions/workflows/ci.yml [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/methods/master [coveralls-url]: https://coveralls.io/r/jshttp/methods?branch=master [node-image]: https://badgen.net/npm/node/methods [node-url]: https://nodejs.org/en/download [npm-downloads-image]: https://badgen.net/npm/dm/methods [npm-url]: https://npmjs.org/package/methods [npm-version-image]: https://badgen.net/npm/v/methods ================================================ FILE: index.js ================================================ /*! * methods * Copyright(c) 2013-2014 TJ Holowaychuk * Copyright(c) 2015-2016 Douglas Christopher Wilson * MIT Licensed */ 'use strict' /** * Module dependencies. * @private */ var http = require('http') /** * Module exports. * @public */ module.exports = getCurrentNodeMethods() || getBasicNodeMethods() /** * Get the current Node.js methods. * @private */ function getCurrentNodeMethods () { return http.METHODS && http.METHODS.map(function lowerCaseMethod (method) { return method.toLowerCase() }) } /** * Get the "basic" Node.js methods, a snapshot from Node.js 0.10. * @private */ function getBasicNodeMethods () { return [ 'get', 'post', 'put', 'head', 'delete', 'options', 'trace', 'copy', 'lock', 'mkcol', 'move', 'purge', 'propfind', 'proppatch', 'unlock', 'report', 'mkactivity', 'checkout', 'merge', 'm-search', 'notify', 'subscribe', 'unsubscribe', 'patch', 'search', 'connect' ] } ================================================ FILE: package.json ================================================ { "name": "methods", "description": "HTTP methods that node supports", "version": "1.1.2", "contributors": [ "Douglas Christopher Wilson ", "Jonathan Ong (http://jongleberry.com)", "TJ Holowaychuk (http://tjholowaychuk.com)" ], "license": "MIT", "repository": "jshttp/methods", "devDependencies": { "eslint": "4.19.1", "eslint-config-standard": "11.0.0", "eslint-plugin-import": "2.13.0", "eslint-plugin-node": "6.0.1", "eslint-plugin-promise": "3.8.0", "eslint-plugin-standard": "3.1.0", "mocha": "10.2.0", "nyc": "15.1.0" }, "files": [ "index.js", "HISTORY.md", "LICENSE" ], "engines": { "node": ">= 0.6" }, "scripts": { "lint": "eslint .", "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "nyc --reporter=lcov --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test" }, "browser": { "http": false }, "keywords": [ "http", "methods" ] } ================================================ FILE: test/.eslintrc.yml ================================================ env: mocha: true ================================================ FILE: test/browserify.js ================================================ var assert = require('assert') var browserify = tryRequire('browserify') var istanbul = tryRequire('istanbul') var methods = null var path = require('path') var run = browserify ? describe : describe.skip var stream = require('stream') var vm = require('vm') run('when browserified', function () { before(function (done) { var b = browserify() var c = {} // instrument if (istanbul && getCoverageGlobal()) { b.transform(istanbulify(c)) } // require methods b.require(path.join(__dirname, '..'), { expose: 'methods' }) // bundle and eval b.bundle(function (err, buf) { if (err) return done(err) var require = vm.runInNewContext(buf.toString(), c) methods = require('methods') done() }) }) describe('methods', function () { ['get', 'post', 'put', 'patch', 'delete'].forEach(function (method) { it('should contain "' + method + '"', function () { assert.notEqual(methods.indexOf(method), -1) }) }) it('should only have lower-case entries', function () { for (var i = 0; i < methods.length; i++) { assert(methods[i], methods[i].toLowerCase(), methods[i] + ' is lower-case') } }) }) }) function getCoverageGlobal () { for (var key in global) { if (key.substr(0, 6) === '$$cov_') { return global[key] } } } function istanbulify (context) { // link coverage context.__coverage__ = getCoverageGlobal() // browserify transform return function (file) { var chunks = [] var instrumenter = new istanbul.Instrumenter() var transformer = new stream.Transform() // buffer chunks transformer._transform = function _transform (data, encoding, callback) { chunks.push(data) callback() } // transform on flush transformer._flush = function _flush (callback) { var contents = Buffer.concat(chunks).toString() instrumenter.instrument(contents, file, function (err, output) { if (err) return transformer.emit('error', err) transformer.push(output) transformer.push(null) callback() }) } return transformer } } function tryRequire (name) { try { return require(name) } catch (e) { return undefined } } ================================================ FILE: test/methods.js ================================================ var http = require('http') var assert = require('assert') var methods = require('..') describe('methods', function () { if (http.METHODS) { it('is a lowercased http.METHODS', function () { var lowercased = http.METHODS.map(function (method) { return method.toLowerCase() }) assert.deepEqual(lowercased, methods) }) } else { it('contains GET, POST, PUT, and DELETE', function () { assert.notEqual(methods.indexOf('get'), -1) assert.notEqual(methods.indexOf('post'), -1) assert.notEqual(methods.indexOf('put'), -1) assert.notEqual(methods.indexOf('delete'), -1) }) it('is all lowercase', function () { for (var i = 0; i < methods.length; i++) { assert(methods[i], methods[i].toLowerCase(), methods[i] + " isn't all lowercase") } }) } })