kepennar / graphQL-server-starter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

graphQL-server-starter

Start

Simple:

npm install
npm start

Developing

With a file watcher (nodemon)

npm run start:dev

Production

Api starter use PM2. You can start it with the Dockerfile provided

docker build -t api-starter .
docker run -p 80:3000 -d api-starter:latest

Config

Easily customizable configuration.

With a .env file in the project root folder

#.env

PORT=3210

Or with environment variables

# Export a variable
export PORT=3210
npm start

# Directly in one command
PORT=3210 npm start

Healthcheck

The awesome GraphQL-starter provide an healthcheck mecanism By default http://localhost:3000/health

{
  "name": "api-starter",
  "version": "0.0.1",
  "checkers": [{ "name": "status", "value": "OK" }]
}

Healthcheck path can be configured

app.use(health('/ping')

Custom checkers can easily be added

app.use(health('/ping', [
  async (ctx, next) => {
    const status = await fetch(serviceUrl).then(res => res.json())
    ctx.body = {
      name: 'custom-check',
      status
    };
    next();
  }
])

About

License:MIT License


Languages

Language:JavaScript 92.8%Language:Shell 3.5%Language:Makefile 2.0%Language:Lua 1.7%