Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/cgi-gin
Connect middleware for a folder of javascript modules
https://github.com/binocarlos/cgi-gin
Last synced: 11 days ago
JSON representation
Connect middleware for a folder of javascript modules
- Host: GitHub
- URL: https://github.com/binocarlos/cgi-gin
- Owner: binocarlos
- License: mit
- Created: 2014-01-18T01:42:00.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-18T02:05:13.000Z (almost 11 years ago)
- Last Synced: 2024-10-06T00:08:27.007Z (about 2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cgi-gin
=======Connect middleware for a folder of javascript modules
## usage
Mount a whole folder of javascript modules onto '/scripts':
```js
var gin = require('../index');
var express = require('express');
var http = require('http');var app = express();
var server = http.createServer(app);app.use('/scripts', gin('/my/folder/of/js/files', {
my:'options'
}))
```A single module (test1.js) in the folder:
```js
module.exports = function(options){// options are the same for each module
return function(req, res, next){
// module code here
}
}
```This script will be run on these urls:
* /scripts/test1
* /scripts/test1.js## installation
```
$ npm install cgi-gin
```## methods
### gin(folder, options)
return a connect middleware that loads all .js files in folder and passes options to the module expecting a middleware function back.
options are the same for each module
## license
MIT