# webwebweb

> The Comfiest Way to make web APIs and static file servers

Latest version **1.6.1** (published 2023-11-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.1 |
| Published | 2023-11-05 |
| First published | 2019-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | Instafluff |
| Maintainers | instafluff |
| Keywords | Instafluff, Comfy, web, api, static, file, http, server |

## Links

- npm: https://www.npmjs.com/package/webwebweb
- Repository: https://github.com/instafluff/WebWebWeb
- Homepage: https://github.com/instafluff/WebWebWeb#readme
- Issues: https://github.com/instafluff/WebWebWeb/issues
- npm.io page: https://npm.io/package/webwebweb

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.6.1 (latest) — 2023-11-05
- 1.6.0 — 2023-05-28
- 1.5.1 — 2023-05-21
- 1.5.0 — 2023-05-21
- 1.4.11 — 2022-11-18
- 1.4.10 — 2021-04-12
- 1.4.9 — 2021-03-08
- 1.4.8 — 2021-03-08
- 1.4.7 — 2021-03-07
- 1.4.6 — 2020-12-29
- 1.4.5 — 2020-12-28
- 1.4.4 — 2020-12-25
- 1.4.3 — 2020-12-22
- 1.4.2 — 2020-12-22
- 1.4.1 — 2020-12-22
- … 18 more at https://npm.io/package/webwebweb/versions

## README

# WebWebWeb
The zero-dependency alternative to ExpressJS. We built the Comfiest Way to make web APIs and static file servers live on Twitch for Coding Cafe!

**WebWebWeb** lets you create a web server with APIs ***SUPER EASILY*** in just a few lines of code.

*If you need a secure web server with SSL certificates from [Let's Encrypt](https://www.letsencrypt.org), check out [WebWebWebs](https://www.github.com/instafluff/WebWebWebs) which will automatically retrieve and renew them for you while maintaining the simplicity of WebWebWeb!*

## Instafluff ##
> *Like these projects? The best way to support my open-source projects is by becoming a Comfy Sponsor on GitHub!*

> https://github.com/sponsors/instafluff

> *Come and hang out with us at the Comfiest Corner on Twitch!*

> https://twitch.tv/instafluff

## Instructions ##

1. Install `webwebweb`
```
npm install webwebweb --save
```

2. Start the server on a port (e.g. 8099). Any HTML pages (e.g. index.html) can be placed in the root directory `/` and static files (e.g. images, scripts, and other HTML pages) can go into `/web` or `/public` and it will be served automagically in `http://locahost:8099/web` or `http://localhost:8099/public`
```javascript
require( "webwebweb" ).Run( 8099 );
```

3. (Optional) Add APIs
```javascript
var ComfyWeb = require( "webwebweb" );
ComfyWeb.APIs[ "/" ] = ( qs, body, opts ) => {
  return { "test": "example!" };
};
ComfyWeb.Run( 8099 );
```

### Options ###

The `Run()` function in **WebWebWeb** accepts several optional parameters:
- useCORS (default: true)
- Certificate
- PrivateKey
- CertificateChain

## Handling POST/PUT/DELETE requests ##
All request methods are sent to the API handler. You can check the `opts.req.method` value to response accordingly and parse the body object for data.
```javascript
var ComfyWeb = require( "webwebweb" );
ComfyWeb.APIs[ "/account" ] = ( qs, body, opts ) => {
    switch( opts.req.method ) {
        case "GET":
            return { "account": "test" };
        case "POST":
            return JSON.parse( body );
        case "PUT":
            return { "status": "updated" };
        case "DELETE":
            return {};
    }
};
ComfyWeb.Run( 8099 );
```

## Reading Request Headers ##
The request object is passed in to the API handler. You can check for header values in `opts.req.headers`.
```javascript
var ComfyWeb = require( "webwebweb" );
ComfyWeb.APIs[ "/" ] = ( qs, body, opts ) => {
    return opts.req.headers;
};
ComfyWeb.Run( 8099 );
```

## Enabling CORS ##
Actually, CORS is enabled by default. To disable CORS, set the `useCORS` parameter:
```javascript
var ComfyWeb = require( "webwebweb" );
ComfyWeb.Run( 8099, {
    useCORS: false
} );
```

## Using SSL Certificates ##
To add TLS support, pass in the paths to your Certificate, Key, and Certificate Chain files:
```javascript
var ComfyWeb = require( "webwebweb" );
ComfyWeb.Run( 8099, {
    Certificate: "cert.pem",
    PrivateKey: "key.pem",
    CertificateChain: "chain.pem"
} );
```

## Credits ##
Thank you to all the participants of this project!

**MacABearMan, Instafriend, That_MS_Gamer, Instafluff, ChatTranslator, sethorizer, simrose4u, Gilokk0, RIKACHET, UltraHal1, SaltPrincessGretchen, Ella_Fint, DutchGamer46, AntiViGames, aj2017, SoundOfGaming, DEAD_P1XL, smilesandtea, MerlinLeWizard, my_sweet_clementine, rockysenpai24, tabetaicooking, sparky_pugwash, violettepanda, TheSkiDragon, radiocaf, LinkoNetwork, jawibae, ElysiaGriffin, DarrnyH, jellydance, DevMerlin, marss112, roberttables, tiger_k1ng, LilyHazel, Psychosys82, BungalowGlow, Stay_Hydrated_Bot, pookiepew, Copperbeardy, TheHugoDahl, wil_bennett, WolvesGamingDen, FuriousFur, SausageCam, Kyoslilmonster, EndlessMoonfall, JD_Hirsch, guthron, shinageeexpress, JMSWRNR, schmiel_show, KitAnnLIVE, space_butts, lukepistachio, pipskidoodle, Kara_Kim, SIeepyMia, itsmechrisg, tapemoose, XandyCTz, Thrennenne, kollecz, Hytheria, YoursTrulyGreed**

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