How to use the http-status.METHOD_NOT_ALLOWED function in http-status

To help you get started, we’ve selected a few http-status examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / taxinomitis / src / lib / restapi / scratch.ts View on Github external
async function getTrainingData(req: Express.Request, res: Express.Response) {
    const apikey = req.params.scratchkey;

    try {
        const scratchKey = await store.getScratchKey(apikey);

        if (scratchKey.type !== 'sounds') {
            return res.status(httpstatus.METHOD_NOT_ALLOWED)
                .json({
                    error : 'Method not allowed',
                });
        }

        const trainingInfo = await store.getSoundTraining(scratchKey.projectid, {
            start : 0,
            limit : 100,
        });

        const trainingData = await Promise.all(trainingInfo.map(getSoundTrainingItem));

        res.set(headers.CACHE_2MINUTES);

        return res.json(trainingData);
    }
github deepstreamIO / deepstream.io / src / connection-endpoint / http / node-server.ts View on Github external
}

     switch (request.method) {
       case 'POST':
         this.handlePost(request, response)
         break
       case 'GET':
         this.handleGet(request, response)
         break
       case 'OPTIONS':
         this.handleOptions(request, response)
         break
       default:
         Server.terminateResponse(
           response,
           HTTPStatus.METHOD_NOT_ALLOWED,
           `Unsupported method. Supported methods: ${this.methodsStr}`
         )
     }
   }
github deepstreamIO / deepstream.io / dist / src / message / http / server.js View on Github external
}
        else {
            response.setHeader('Access-Control-Allow-Origin', '*');
        }
        switch (request.method) {
            case 'POST':
                this._handlePost(request, response);
                break;
            case 'GET':
                this._handleGet(request, response);
                break;
            case 'OPTIONS':
                this._handleOptions(request, response);
                break;
            default:
                Server._terminateResponse(response, HTTPStatus.METHOD_NOT_ALLOWED, `Unsupported method. Supported methods: ${this.methodsStr}`);
        }
    }
    _verifyOrigin(request, response) {
github deepstreamIO / deepstream.io / src / services / http / node / node-http.ts View on Github external
}

     switch (request.method) {
       case 'POST':
         this.handlePost(request, response)
         break
       case 'GET':
         this.handleGet(request, response)
         break
       case 'OPTIONS':
         this.handleOptions(request, response)
         break
       default:
         this.terminateResponse(
           response,
           HTTPStatus.METHOD_NOT_ALLOWED,
           `Unsupported method. Supported methods: ${this.methodsStr}`
         )
     }
   }
github jimschubert / yfa-nodejs-code / code / yfa / src / routes / users.js View on Github external
exports.create = function (req, res) {
    res.problem(HttpStatus.METHOD_NOT_ALLOWED,
        "You're not allowed to create users on this system",
        "Users are created via 3rd party (Facebook) authentication");
};