api.js 545 B

12345678910111213141516171819202122232425262728
  1. var trim = require('../utils/trim');
  2. function parse(content) {
  3. content = trim(content);
  4. // Search: type, url and title
  5. // Example: {get} /user/:id Get User by ID.
  6. var parseRegExp = /^(?:(?:\{(.+?)\})?\s*)?(.+?)(?:\s+(.+?))?$/g;
  7. var matches = parseRegExp.exec(content);
  8. if ( ! matches)
  9. return null;
  10. return {
  11. type : matches[1],
  12. url : matches[2],
  13. title: matches[3] || ''
  14. };
  15. }
  16. /**
  17. * Exports
  18. */
  19. module.exports = {
  20. parse : parse,
  21. path : 'local',
  22. method: 'insert'
  23. };