Socket
Socket
Sign inDemoInstall

bees

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 0.0.4

lib/plugins/param.js

32

lib/bees.js

@@ -1,2 +0,7 @@

var bees = module.exports = function(file) {
var plugins = {
"return": require('./plugins/return'),
"param" : require('./plugins/param')
};
exports.parse = function bees(file) {
var matches = file.match(/\/\*{1,2}(.|\n)+?\*\//g),

@@ -12,5 +17,8 @@ json = [];

m.shift();
m.map(function(i) {
i = i.replace(/\*/g, '').trim();
i = i.replace(/\*/g, '')
.trim();
if(!i.length) return;

@@ -22,14 +30,6 @@

switch(cmd[0]) {
case 'param':
var datas = cmd[1].match(/(\w+)\s([\W\w]+)?/)
datas.shift();
sub.params = sub.params || {};
sub.params[datas[0]] = datas[1];
break;
case 'return':
sub.return = cmd[1];
break;
if(plugins[cmd[0]]) {
plugins[cmd[0]](cmd, sub);
}
}

@@ -46,3 +46,7 @@ else {

return JSON.stringify(json, null, 2);
return json;
};
exports.use = function(name, fn) {
plugins[name] = fn;
};
{
"name": "bees",
"version": "0.0.3",
"version": "0.0.4",
"author": "yawnt <yawn.localhost@gmail.com>",

@@ -5,0 +5,0 @@ "description": "HTTP API Generator",

@@ -7,3 +7,3 @@ bees (in Italian ```API``` means ```bees```)

## Install
## Installation:

@@ -64,4 +64,39 @@ ```

## To Do
## Plugin:
You can extend Bees and add new keywords with a tiny plugin system (see ```lib/plugins```)
```javascript
var bees = require('bees');
bees.use('plugin', function(cmd, json) {
json.plugin = cmd[1];
});
console.log(
bees.parse(
require('fs').readFileSync('./app.js','utf-8')
)
);
```
Now you can use it
```javascript
/**
* GET /:id
*
* @param id id of the user
* @return user infos
* @plugin hai lol
*/
```
```
$ node plugin.js
```
## To Do:
- Generate HTML from JSON

@@ -76,1 +111,5 @@

Tests are written with Vows
## License:
__MIT__

@@ -12,7 +12,21 @@ var vows = require('vows'),

'example.js': {
topic: bees(example),
topic: bees.parse(example),
'should return correct json': function(json) {
assert.equal(
assert.deepEqual(
json,
'[{"method":"GET","path":"/","return":"Main page"},{"method":"GET","path":"/:id","params":{"id":"id of the user"},"return":"user infos"}]'
[
{
"method": "GET",
"path": "/",
"return": "Main page"
},
{
"method": "GET",
"path": "/:id",
"params": {
"id": "id of the user"
},
"return": "user infos"
}
]
);

@@ -19,0 +33,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc