• Stars
    star
    348
  • Rank 121,840 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿš„ A Yeoman generator for Express.js based 12-factor apps and apis using Typescript

generator-express-no-stress-typescript

Codacy Badge All Contributors

![](https://img.shields.io/badge/license-MIT-blue.svg)

Create awesome Express.js applications with best of breed tech including Typescript, structured logging with Pino, API validation and interactive documentation via an OpenAPI 3 or Swagger 2 spec, environment based config with dotenv.

generator-express-no-stress-typescript gets you up and running in seconds. It's ridiculously easy to configure. Heck, just take the defaults. Start it. Write code.

This generator scaffolds a fully functioning REST API server complete with interactive documentation, API validation, structured logging, environment driven config, and more. Simply run the generator and smile :-D

This project is a Typescript variant of generator-express-no-stress

Here's what you get!

Install

Requires Node 6 or greater

npm install -g yo generator-express-no-stress-typescript
  • See here for use with Yarn and/or Docker

Scaffold

yo express-no-stress-typescript 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 express-no-stress-typescript [appname] [--yarn] [--docker]
Option default Description
appname myapp The application folder
--yarn - Use the yarn package manager, instead of npm
--docker Install Docker artifacts including a Dockerfile

Usage: Project

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

npm targets

Target Description
npm run dev Run in development mode
npm run dev:debug Debug in development mode
npm run test Run tests
npm run test:debug Debug tests
npm run compile Transpile source code for production use
npm start Run the in production mode. *Requires running npm run compile first

Deploy to the Cloud

e.g. CloudFoundry

cf push myapp

Use Yarn

# scaffold
yo express-no-stress-typescript 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

API Validation!

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

Structured Logging

Structured logging out of the box!

raw

pretty

Structured logging pretty printed by default - great for dev!

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

FAQ

Q: How do I modify the example API and make it my own?

A: There are two key files that enable you to customize and describe your API:

  1. server/routes.ts - This references the implementation of all of your routes. Add as many routes as you like and point each route your express handler functions.
  2. server/common/api.yaml - This file contains your OpenAPI spec. Describe your API here. It's recommended that you to declare any and all validation logic in this YAML. express-no-stress-typescript uses express-openapi-validator to automatically handle all API validation based on what you've defined in the spec.

Q: I previously generated an app, but I want to change the API root. How do I do this?

A: You need to make to small changes

  1. Modify server/routes.ts
   // Change your original path e.g. /api/v1/examples, to:
   app.use('/api/v2/examples', examplesRouter);
  1. Modify server/common/api.yaml and update the api root:
  # Change e.g. /api/v1 to /api/v2
  servers:
  - url: /api/v2   

License

MIT

Buy Me A Coffee

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Harris Brakmiฤ‡

๐Ÿ’ป

Daniel Meyer

๐Ÿ“–

Viraj Trivedi

๐Ÿ’ป

Sangbeom Han

๐Ÿ“–

Stef de Goey

๐Ÿ’ป

Roger

๐Ÿ’ป

Vikash Chauhan

๐Ÿ’ป ๐Ÿ“–

Tse Kit Yam

๐Ÿ“– ๐Ÿ’ป

Randy Kamradt

๐Ÿ’ป

Vitthal Patil

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

express-openapi-validator

๐Ÿฆ‹ Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
TypeScript
914
star
2

generator-express-no-stress

๐Ÿš‚ A Yeoman generator for Express.js based 12-factor apps and apis
JavaScript
579
star
3

dotenv-kotlin

๐Ÿ—๏ธ Dotenv is a module that loads environment variables from a .env file
Kotlin
414
star
4

dotenv-java

๐Ÿ—๏ธ Dotenv is a no-dep, pure Java module that loads environment variables from a .env file
Java
308
star
5

py-readability-metrics

๐Ÿ“— Score text readability using a number of formulas: Flesch-Kincaid Grade Level, Gunning Fog, ARI, Dale Chall, SMOG, and more
Python
281
star
6

kotlin-openapi-spring-functional-template

๐Ÿƒ Kotlin Spring 5 Webflux functional application with api request validation and interactive api doc
Kotlin
177
star
7

essence

Automatically extract the main text content (and more) from an HTML document
Kotlin
105
star
8

uuid-mongodb

๐Ÿ“‡ Generates and parses MongoDB BSON UUIDs
JavaScript
97
star
9

openapi-spring-webflux-validator

๐ŸŒฑ A friendly kotlin library to validate API endpoints using an OpenApi 3.0 and Swagger 2.0 specification
Kotlin
93
star
10

node-mongodb-fixtures

๐Ÿ Setup and tear down test fixtures with MongoDB.
JavaScript
90
star
11

lambda-zsh-theme

ฮป Beautiful lambda theme for Zsh
58
star
12

nationalparks_conversation

Chatbots and Watson: Letโ€™s talk about national parks: course source code
JavaScript
46
star
13

java-dotenv

Use dotenv-java or dotenv-kotlin https://github.com/cdimascio/dotenv-java or https://github.com/cdimascio/dotenv-kotlin instead
24
star
14

kotlin-spring-mvc-template

12-factor compliant Spring MVC Kotlin template. Features automatic request/response validation and interactive API doc
Kotlin
22
star
15

react-native-share-sheet

iOS share sheet for React Native
Objective-C
11
star
16

dbpedia-sparql-client

A promisified DBpedia SPARQL client that keeps it simple.
JavaScript
10
star
17

express-openapi-validator-example

simple openapi validation examplewith express-openapi-validator
JavaScript
9
star
18

watson-nlc-spam

Create a spam classifier with Watson Natural Language Classifier.
CSS
9
star
19

gin-openapi

Automatically validates API requests against an OpenAPI 3 spec.
Go
6
star
20

cloudant-upsert

A no-dependency module that adds 'upsert' to Node.js Cloudant
JavaScript
5
star
21

couchinator

๐Ÿ›‹๏ธ Fixtures for CouchDB and IBM Cloudant: Create and teardown cloudant dbs
JavaScript
5
star
22

japi-errors

โšกCustomizable errors for RESTful and HTTP services.
Java
4
star
23

md5-nodejs

A node module that hashes data to MD5.
JavaScript
4
star
24

mongoose-compose-example

An example to quickly get your up and running with Mongoose and MongoDB on IBM Compose.io.
JavaScript
4
star
25

ya-angular-requirejs-seed

Seed for AngularJs and require.js
JavaScript
3
star
26

essence-web

JavaScript
3
star
27

couchinator-java-wrapper

Fixtures for CouchDB and IBM Cloudant.
Java
3
star
28

sqs-replay

โ™ป๏ธ CLI that replays AWS SQS messages between queues.
Rust
2
star
29

my-projects

A list of newsworthy projects that I led or was key contributor
2
star
30

md5-to-uuid

A node module that converts MD5 hashes to UUIDs.
JavaScript
2
star
31

aws-config-manager

Manage multiple AWS credentials and config files
Go
2
star
32

wcp-errors

Generate normalized http error messages
JavaScript
2
star
33

express-no-stress-openapi3-example

JavaScript
2
star
34

bunyan-decorator

bunyan log decorator for es6 class methods
JavaScript
1
star
35

java-dotenv-example

Java
1
star
36

scripts

Shell
1
star
37

aws-credentials-manager

Utility for managing multiple AWS credentials files.
Shell
1
star
38

woh-deploy

CSS
1
star
39

homebrew-tap

Ruby
1
star
40

rails-example

Ruby
1
star
41

docker-images

Dockerfile
1
star
42

lerna-test

JavaScript
1
star
43

flagger-on

๐Ÿฆฉ fast, feature flags with percentage rollout
TypeScript
1
star
44

keras_nns

Python
1
star
45

cdimascio.github.io

Personal website
CSS
1
star
46

nlu-news-web

Sample application using Watson Natural Language Understand and IBM Cloud Functions
JavaScript
1
star
47

mixpanel-export-java

Lightweight export library for Mixpanel
Java
1
star
48

node-api-errors

JavaScript
1
star
49

cdimascio-card

๐Ÿ“› Carmine's card
JavaScript
1
star
50

me-web

JavaScript
1
star
51

vue-webqr

JavaScript
1
star
52

ballparks

Source code for developerWorks article: Create a baseball-themed app powered by Weather Company Data for IBM Bluemix and DBpedia
JavaScript
1
star