> 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

A simple express middleware to password-protect your pages

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="https://1533853801-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQO6kz0zi00Gb8s1C7jDL%2Fuploads%2FtQF9VJO4KQMxeMkCIr7U%2FScreen%20Shot%202022-07-09%20at%203.37.53%20PM.png?alt=media&amp;token=456acfe7-26aa-4a7e-b73f-9e7c185938be" 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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://pagelock.coolstone.dev/pagelock.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
