# caviar

> A pluggable and extendable web framework which integrates React, Next and Koa to create your own web application out of the box with even zero configuration

Latest version **6.0.1** (published 2019-09-19) · MIT license · 0 weekly downloads

## Install

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

## 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 | 6.0.1 |
| Published | 2019-09-19 |
| First published | 2017-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 8 |
| Dependencies | 10 |
| Unpacked size | 48.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | kaelzhang |
| Maintainers | kael |
| Keywords | caviar, skeleton, frameworks, web framework, micro-frontends, frontends, config chain, config layer, blocks, BFF, backend-for-frontend |

## Links

- npm: https://www.npmjs.com/package/caviar
- Repository: https://github.com/kaelzhang/caviar
- Homepage: https://github.com/kaelzhang/caviar#readme
- Issues: https://github.com/kaelzhang/caviar/issues
- npm.io page: https://npm.io/package/caviar

## Dependencies (10)

- [tapable](https://npm.io/package/tapable.md) ^1.1.3
- [err-object](https://npm.io/package/err-object.md) ^5.1.4
- [env-to-code](https://npm.io/package/env-to-code.md) ^1.0.4
- [is-absolute](https://npm.io/package/is-absolute.md) ^1.0.0
- [core-util-is](https://npm.io/package/core-util-is.md) ^1.0.2
- [has-own-prop](https://npm.io/package/has-own-prop.md) ^2.0.0
- [resolve-from](https://npm.io/package/resolve-from.md) ^5.0.0
- [object-access](https://npm.io/package/object-access.md) ^2.0.4
- [tapable-proxy](https://npm.io/package/tapable-proxy.md) ^1.0.4
- [require-esmodule](https://npm.io/package/require-esmodule.md) ^1.0.1

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 6.0.1 (latest) — 2019-09-19
- 6.0.0 — 2019-09-16
- 5.5.0 — 2019-09-16
- 5.4.2 — 2019-09-09
- 5.4.1 — 2019-09-08
- 5.4.0 — 2019-09-07
- 5.3.0 — 2019-09-06
- 5.2.1 — 2019-09-06
- 5.2.0 — 2019-09-05
- 5.1.0 — 2019-09-04
- 5.0.1 — 2019-09-04
- 5.0.0 — 2019-09-02
- 4.0.1 — 2019-08-21
- 3.0.2 — 2019-07-24
- 3.0.1 — 2019-07-09
- … 32 more at https://npm.io/package/caviar/versions

## README

# ![caviar](logo/readme.png)

[![Build Status](https://travis-ci.org/caviarjs/caviar.svg?branch=master)](https://travis-ci.org/caviarjs/caviar)
[![Coverage](https://codecov.io/gh/caviarjs/caviar/branch/master/graph/badge.svg)](https://codecov.io/gh/caviarjs/caviar)

> ⚠️ This document is out-of-date

A pluggable and extendable skeleton which help to integrate several existing web frameworks to create your own micro frontends out of the box with even zero configuration.

> An architectural style where independently deliverable frontend applications are composed into a greater whole

## Getting Started

```sh
mkdir hello && cd hello
yo generator-caviar
npm run dev
```

Yeah, we have our first application

### File Structure

```
project/
|-- app
|-- pages
|-- caviar.config
|   |-- .env
|   |-- client.env
|   |-- index.js
|-- package.json
|-- ...
```

## Thinking in `caviar`

****

> The sections below is for development purpose

## Extend `caviar` for your own business

### Config chain

## How to write caviar plugins

## API Documentation

```js
const {
  Sandbox,
  Server,
  ConfigLoader
} = require('caviar')
```

### new Sandbox(options)

- **options** `Object`
  - **cwd** `path` the current working directory
  - **port?** `number` server port
  - **dev?** `boolean=false` whether is for development purpose
  - **serverClassPath?** `path` the file path of the `Server` class. Defaults to the `Server` class path of the `caviar` project.
  - **configLoaderClassPath?** `path` the file path of the `ConfigLoader` class

Creates a new sandbox. Sandbox is design to filter the environment variables.

#### await sandbox.start(): ChildProcess

Start the sandbox, and it will create a new `Server` by passing `{cwd, port, dev}` as options.

### new Server(options)

- **options** `Object`
  - **cwd**
  - **port?** `Number` `options.port` will override `config.port` of `caviar.config.js`
  - **dev?**
  - **configLoaderClassPath?**

Create a new `Server`

```js
const server = new Server({
  cwd,
  dev: true
})

await server.ready()
server.listen(8888)
```

#### await server.ready(): this

Initialize the server

#### server.callback(): Function

Returns a callback function suitable for the `http.createServer()` method to handle a request.

```js
require('http')
.createServer(server.callback())
.listen(8888)
```

This method must **NOT** be called before the server is ready (`await server.ready()`)

#### server.listen(port?): Promise

- **port?** `number` optional server port. If `port` is specified, it will override `options.port`.
- **callback?** `Function`

## License

[MIT](LICENSE)

****

<p align="right">Thanks <a href="https://github.com/reallinfo">@reallinfo</a> for the great logo<p>

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