4.5.0 • Published 6 years ago

generator-tk-service v4.5.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

generator-tk-service

Here's what you get!

Install

Requires Node 6 or greater

npm install -g yo generator-tk-service
  • See here for use with Yarn and/or Docker

Scaffold

yo tk-service myapp
cd myapp

Run

Run in development mode:

npm run dev

Package and run in production mode

npm run compile
npm start

Test

npm test

Debug

Run one of the following, then attach your favorite inspector.

# debug the server
npm run dev:debug

# debug the tests
npm run test:debug

Try it!


Usage: CLI

yo tk-service [appname] [--yarn] [--docker]
OptiondefaultDescription
appnamemyappThe application folder
--yarn-Use the yarn package manager, instead of npm
--dockerInstall Docker artifacts including a Dockerfile

Usage: Project

The sections below describe all usage options available once the project is generated/scaffolded.

npm targets

TargetDescription
npm run devRun in development mode
npm run dev:debugDebug in development mode
npm run testRun tests
npm run test:debugDebug tests
npm run compileTranspile source code for production use
npm startRun the in production mode. *Requires running npm run compile first

Deploy to the Cloud

e.g. CloudFoundry

cf push myapp

Use Yarn

# scaffold
yo tk-service myapp --yarn

# start
cd myapp
npm start

What you get!

  • Typescript - Typescript is a typed superset of JavaScript that compiles to plain JavaScript
  • Express.js - Fast, unopinionated , minimalist web framework for Node.js
  • Pino - Extremely fast node.js logger, inspired by Bunyan. It also includes a shell utility to pretty-print its log files
  • dotenv - Loads environment variables from .env for nodejs projects
  • Swagger - is a simple yet powerful representation of your RESTful API.
  • SwaggerUI - dynamically generate beautiful documentation and sandbox from a Swagger-compliant API

API Validation

Simply describe your APIs with Swagger and automagically get for free:

  • Interactive documentation
  • API validation

Interactive API Doc

npm.io

API Validation!

Oops! I the API caller forgot to pass a name field, no stress, we've got this!

npm.io

Structured Logging

Structured logging out of the box!

raw

npm.io

pretty

Structured logging pretty printed by default - great for dev!

npm.io

API Validation Example

Simply describe your APIs with Swagger and automatically get:

  • API request validation
  • Interactive documentation

example

Swagger API spec

swagger: '2.0'
info:
  version: 1.0.0
  title: myapp
  description: My cool app
basePath: /api/v1
tags:
  - name: Examples
    description: Simple example endpoints
  - name: Specification
    description: The swagger API specification

consumes:
  - application/json
produces:
  - application/json

definitions:
  ExampleBody:
    type: object
    title: example
    required:
      - name
    properties:
      name:
        type: string
        example: no_stress

paths:
  /examples:
    get:
      tags:
        - Examples
      description: Fetch all examples
      responses:
        200:
          description: Returns all examples
    post:
      tags:
        - Examples
      description: Create a new example
      parameters:
        - name: example
          in: body
          description: an example
          required: true
          schema:
            $ref: '#/definitions/ExampleBody'
      responses:
        200:
          description: Returns all examples

  /examples/{id}:
    get:
      tags:
        - Examples
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the example to retrieve
          type: integer
      responses:
        200:
          description: Return the example with the specified id
        404:
          description: Example not found

  /spec:
    get:
      tags:
        - Specification
      responses:
        200:
          description: Return the API specification

Invoke a POST request via the Interactive doc

npm.io

License

MIT

4.5.0

6 years ago

4.4.11

6 years ago

4.4.10

6 years ago

4.4.9

6 years ago

4.4.8

6 years ago

4.4.7

6 years ago

4.4.6

6 years ago

4.4.5

6 years ago

4.4.4

6 years ago

4.4.3

6 years ago

4.4.2

6 years ago

4.4.1

6 years ago

4.3.11

6 years ago

4.3.10

6 years ago

4.3.9

6 years ago

4.3.8

6 years ago

4.3.7

6 years ago

4.3.6

6 years ago

4.3.5

6 years ago

4.3.4

6 years ago

4.3.3

6 years ago

4.3.2

6 years ago

4.3.1

6 years ago

4.3.0

6 years ago

4.2.9

6 years ago

4.2.8

6 years ago

4.2.7

6 years ago

4.2.5

6 years ago

4.2.4

6 years ago

4.2.3

6 years ago

4.2.2

6 years ago

4.2.1

6 years ago

4.2.0

6 years ago