How to use the methods.map function in methods

To help you get started, we’ve selected a few methods 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 ruyadorno / snapstub / commands / start.js View on Github external
function printRoutes(srcPath, port) {
	const patterns = methods.map(m => `**/${m}.+(json|js)`);

	globby(patterns, {cwd: srcPath})
		.then(paths => {
			const routes = paths.map(p => {
				// Remove filename from path
				const directoryPath = p.substring(0, p.lastIndexOf('/'));

				return `http://localhost:${port}/${directoryPath}`;
			});
			for (let route of new Set(routes)) {
				out.info(route);
			}
		});
}
github koajs / trie-router / lib / routes.js View on Github external
var compose = require('koa-compose')
var isGenFun = require('is-gen-fn')
var flatten = require('flatten')
var assert = require('assert')
var METHODS = require('methods').map(function (method) {
  return method.toUpperCase()
})

var Router = require('./router')

Router.prototype.routes = function () {
  var router = this
  var app = this.app

  // app.route(paths).get(gen).post(gen)
  app.route = function () {
    return new Route(router, [].slice.call(arguments))
  }

  // app.get(paths, gen, gen ,gen)
  METHODS.forEach(function (method) {