# @lukas3674/hbs-web-server

> A simple js web-server with hbs

Latest version **1.1.2** (published 2019-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lukas3674/hbs-web-server
pnpm add @lukas3674/hbs-web-server
yarn add @lukas3674/hbs-web-server
bun add @lukas3674/hbs-web-server
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2019-08-17 |
| First published | 2019-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Lukas Hassler |
| Maintainers | lukas3674 |
| Keywords | simple, js, web, server, hbs |

## Links

- npm: https://www.npmjs.com/package/@lukas3674/hbs-web-server
- npm.io page: https://npm.io/package/@lukas3674/hbs-web-server

## Dependencies (4)

- [express](https://npm.io/package/express.md) ^4.17.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [cookie-session](https://npm.io/package/cookie-session.md) ^1.3.3
- [express-handlebars](https://npm.io/package/express-handlebars.md) ^3.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.2 (latest) — 2019-08-17
- 1.1.1 — 2019-08-17
- 1.1.0 — 2019-08-17
- 1.0.2 — 2019-08-16
- 1.0.1 — 2019-08-15
- 1.0.0 — 2019-08-14

## README

# Simple JS Web-Server with HBS

## Usage:
#### Folder-Structure
```
>your_project
    >hbs
        >layouts
            >layout.hbs
        >public
            >js
                script.js
            ...
        >views
            >view.hbs
    >index.js
    >...
```

#### index.js
```js

const WS = require(`@lukas3674/hbs-web-server`);
const path = require(`path`);

const ws = new WS({
    port: 8888,
    cookieKey: `justSomeRandomKey`,
    hbsDir: path.join(__dirname, `hbs`),
}).start();

ws.get(`/`, (req, res) => {
    res.render(`view`, {
        title: `Test Website`,
        text: `My test website text ...`
    });
});

ws.get(`/stop`, (req, res) => {
    res.send(`stopped`);
    ws.stop();
});
```

#### layout.hbs
```html
<!DOCTYPE html>
<html style="background-color: #000000">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script type="text/javascript" src="js/script.js"></script>

        {{#if title}}
            <title>{{title}}</title>
        {{/if}}
    </head>
    <body>
        {{{body}}}
    </body>
</html>
```

#### view.hbs
```html
<div style="color: #ffffff">
    {{#if text}}
        <h1 style="text-align: center">{{text}}</h1>
    {{/if}}
</div>
```

#### script.js
```js
console.log(`Hello Website!`);
```

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