# potatoprotocol

> Use PBP nodejs package to create your own sites on potato browser.

Latest version **0.0.3** (published 2023-09-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install potatoprotocol
pnpm add potatoprotocol
yarn add potatoprotocol
bun add potatoprotocol
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-09-24 |
| First published | 2023-09-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | vnti |
| Maintainers | vnti |
| Keywords | pbp, tor |

## Links

- npm: https://www.npmjs.com/package/potatoprotocol
- npm.io page: https://npm.io/package/potatoprotocol

## Dependencies (3)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^4.7.2

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2023-09-24
- 0.0.2 — 2023-09-23
- 0.0.1 — 2023-09-23

## README

# pbp njs

## Example:

index.js
```
const Potato = require('./potato');
const ejs = require('ejs'); 

const domain = "base.net"; // domain, change it to whatever u want
const potato = new Potato(domain);

// using files + <## variables ##>
potato.use("", (skin) => {
  console.log("main page visited by " + skin.id);
  skin.render("index.html", { name: "vnti" });
});


// using plain display + ejs
potato.use('help/:text', (skin) => {
  const text = skin.params.text;
  console.log("someone visited the help page with param:", text);
  const template = `
     <!DOCTYPE html>
    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <style>
        body {
          background-color: rgb(16,0,0);
          color: white !important;
        }
      </style>
    </head>
    <body>   
      <h1>help for <%= text %>:\n</h1>
    </body>
   
  `;
  const renderedContent = ejs.render(template, { text });
  skin.display(renderedContent);
});

// custom 404 page
potato.setNotFoundCallback((data) => {
  const template = `
    <!DOCTYPE html>
    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>   
      <h1><a href="pbp://${domain}/help/idk">come back home</a></h1>
    </body>
  `;
  const renderedContent = ejs.render(template, {});
  potato.do('show', { ...data, content: renderedContent });
});

potato.run()
```
/views/index.html
```
<!DOCTYPE html>
<html>
    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <style>
        body {
          background-color: #000000;
          color: white !important;
        }
      </style>
    </head>
    <body>   
      <h1>you have visited main page! my name is <a href="pbp://base.net/help/idk"><## name ##></a></h1>
    </body>
</html>
```

---
_Source: https://npm.io/package/potatoprotocol · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
