Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jameskyburz/server-base

base for micro services or simple servers
https://github.com/jameskyburz/server-base

fasthttp fasthttprouter http http-framework microservices nodejs server server-base server-base-logger

Last synced: about 2 months ago
JSON representation

base for micro services or simple servers

Awesome Lists containing this project

README

        

# server base

base for micro services or simple servers

[![js-standard-style](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/feross/standard)
[![build status](https://github.com/JamesKyburz/server-base/actions/workflows/main.yml/badge.svg)](https://github.com/JamesKyburz/server-base/actions/workflows/main.yml)
[![downloads](https://img.shields.io/npm/dm/server-base.svg)](https://npmjs.org/package/server-base)

### usage

```javascript
const service = require('server-base')
service({
'@setup': (ctx, router) => {
ctx.use([
(req, res, next) => next()
])
ctx.onError([
(req, res, error, next) => next()
])
},
'/graphql': {
get (req, res) {
res.end('html')
},
async post (req, res) {
const query = await req.json()
res.json({})
}
}
})
.start(5000)
```

### router

See [server-base-router](https://github.com/JamesKyburz/server-base/tree/master/packages/server-base-router) for details.

See [server-base-router-tests](https://github.com/JamesKyburz/server-base/tree/master/packages/server-base-router/test) for details.

### logger

See [server-base-log](https://github.com/JamesKyburz/server-base/tree/master/packages/server-base-log) for details.

### .env

If a .env file exists it will load the values into process.env using [dotenv](https://npm.im/dotenv).

```dosini
PORT=1900
```

# install

With [npm](https://npmjs.org) do:

```
npm install server-base
```

# license
[Apache License, Version 2.0](LICENSE)