Skip to content

Commit

Permalink
docs: Document configuration settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
amiller-gh authored Jan 4, 2020
1 parent dd37421 commit 0b1dc02
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,44 @@ Loll enables you to use the file system to declare RESTful API endpoints for you

## How To Use

Simply:
#### To install, simply:
``` Shell
npm install --save loll
### or ###
yarn add loll
```

Then, in your app.js file:
#### Then, in your app.js file:
``` JavaScript
// Get our dependencies
const express = require('express');
const api = require('loll');
const loll = require('loll');

// Init Core
const app = express();
app.set('port', 8080);


/*******************************************
Additional Middleware Go Here
*******************************************/

// Automatically discover API endpoints. Defaults to the `/api` directory.
app.use('/api', api(express));
app.use('/api', loll(express));

// Start Server
http.createServer(app).listen(app.get('port'), function(){
console.log(('Express server listening on port ' + app.get('port')));
http.createServer(app).listen(app.get('port'), () => {
console.log(`Express server listening on port ${app.get('port')}`);
});
```

#### Configuration
Loll takes an optional configuration hash as a second argument that accepts the following settings.

| Name | Type | Default | Description |
|:-------|:-------|:----------------------------------|:-------------------------------------------------------------|
| `root` | String | `path.join(process.cwd(), 'api')` | The directory that Loll will crawl to discover API endpoints |


## How It Works

Its quite simple really – the Loll middleware will attempt to route an xhr or JSON compatible HTTP request to an API endpoint defined by the structure your project's `/api` directory, and send the JSON response back to the client.
Expand Down

0 comments on commit 0b1dc02

Please sign in to comment.