Update Node.js handler doc (#2764)

This commit is contained in:
Yadd 2022-06-23 12:27:35 +02:00
parent 46d43e69d9
commit 3c6bb15b34
1 changed files with 22 additions and 19 deletions

View File

@ -12,13 +12,13 @@ Examples
**Important things**:
- The above examples below are written for version 0.6.0 in CommonJS
but Node.js handler can be used in ES7 and/or Typescript code
- Rules and headers must be written in javascript for these hosts
(example ``$uid eq "dwho"`` becomes ``$uid === "dwho"``)
- Multi-lines are not supported in lemonldap-ng.ini
- Virtualhosts handled by node-lemonldap-ng-handler must be explicitly
declared in your ``lemonldap-ng.ini`` file in ``[node-handler]``
section (**NB**: section ``[handler]`` isn't used by node
handler):
section
.. code-block:: ini
@ -40,12 +40,14 @@ FastCGI server
configStorage: {
"confFile": "/path/to/lemonldap-ng.ini"
}
});
}).then( () => {
handler.nginxServer({
"mode": "fcgi", // or "http", default: fcgi
"port": 9090, // default value
"ip": 'localhost' // default value
});
handler.nginxServer({
"mode": "fcgi", // or "http", default: fcgi
"port": 9090, // default value
"ip": 'localhost' // default value
});
Nginx configuration
@ -98,16 +100,17 @@ Use it to protect an express app
configStorage: {
"confFile":"test/lemonldap-ng.ini"
}
});
// and load it
app.use(handler.run);
// Then simply use your express app
app.get('/', function(req, res) {
return res.send('Hello ' + req.headers['Auth-User'] + ' !');
});
app.listen(3000, function() {
return console.log('Example app listening on port 3000!');
}).then( () => {
// and load it
app.use(handler.run);
// Then simply use your express app
app.get('/', function(req, res) {
return res.send('Hello ' + req.headers['Auth-User'] + ' !');
});
app.listen(3000, function() {
return console.log('Example app listening on port 3000!');
});
});