Skip to content

Commit

Permalink
Adjusted readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
gevorg committed Jun 24, 2021
1 parent 88092c2 commit 7167e06
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,34 @@ Via [npm](http://npmjs.org/):
$ npm install http-auth
```

## Examples
## Usage

```javascript
// HTTP module
const http = require("http");

// Authentication module.
const auth = require("http-auth");
const basic = auth.basic({
realm: "Simon Area.",
file: __dirname + "/../data/users.htpasswd" // gevorg:gpass, Sarah:testpass
});

// Creating new HTTP server.
http
.createServer(
basic.check((req, res) => {
res.end(`Welcome to private area - ${req.user}!`);
})
)
.listen(1337, () => {
// Log URL.
console.log("Server running at http://127.0.0.1:1337/");
});
```

Please check [examples directory](./examples) for more.

Please check [examples directory.](./examples)
## Configurations

- `realm` - Authentication realm, by default it is **Users**.
Expand Down

0 comments on commit 7167e06

Please sign in to comment.