> For the complete documentation index, see [llms.txt](https://pagelock.coolstone.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pagelock.coolstone.dev/pagelock.md).

# Pagelock

Want to password-protect an Express endpoint? Use Pagelock! When attempting to access a locked page, an "Enter code" page will show up, if you enter the code correctly, the page will be replaced with the file you specified.

<figure><img src="/files/5aRhkx4nPoPVH6F2tClZ" alt="Lock page"><figcaption><p>Default lock page</p></figcaption></figure>

### Install the package

```bash
npm i pagelock
```

### Initialize

{% code lineNumbers="true" %}

```javascript
const app = require("express")() 
const pagelock = require('pagelock')
const lock = pagelock('password', { config:"here" })

app.get('/*', lock, (req, res) => {
res.send('Hello World')
})

app.listen(3000)
```

{% endcode %}

### Arguments

| Name     | About              | Type   |
| -------- | ------------------ | ------ |
| password | Password           | String |
| config   | More details below | Object |

### Configuration

| Name          | About                                                                                                 | Type               |
| ------------- | ----------------------------------------------------------------------------------------------------- | ------------------ |
| espionageMode | Allow junk to be on either side of real code. (EX: Code is 1234, Pagelock will accept 555**1234**666) | Bool               |
| caseSensitive | If code needs to match case.                                                                          | Bool               |
| css           | Custom CSS                                                                                            | String (File path) |

### NPM Page

{% embed url="<https://npmjs.com/package/pagelock>" %}

### License

Pagelock is available under the MIT License
