All Projects → nfroidure → whook

nfroidure / whook

Licence: MIT license
Build strong and efficient REST web services.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to whook

ogen
OpenAPI v3 code generator for go
Stars: ✭ 436 (+2322.22%)
Mutual labels:  openapi, openapi3
swagger-converter
OpenAPI/Swagger 2.0 to OpenAPI 3.0 Converter WebService
Stars: ✭ 58 (+222.22%)
Mutual labels:  openapi, openapi3
specifications-ITS-REST
openEHR REST API Specifications
Stars: ✭ 20 (+11.11%)
Mutual labels:  openapi, openapi3
openapi-boilerplate
📘 Multi-file boilerplate for Open API Specification
Stars: ✭ 280 (+1455.56%)
Mutual labels:  openapi, openapi3
openapi4j
OpenAPI 3 parser, JSON schema and request validator.
Stars: ✭ 92 (+411.11%)
Mutual labels:  openapi, openapi3
OpenAPI
A pharo implementation of OpenAPI 3.0.1
Stars: ✭ 20 (+11.11%)
Mutual labels:  openapi, openapi3
loopback-next
LoopBack makes it easy to build modern API applications that require complex integrations.
Stars: ✭ 4,412 (+24411.11%)
Mutual labels:  dependency-injection, openapi
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+19055.56%)
Mutual labels:  openapi, openapi3
intellij-openapi-generator
Intellij Plugin for openapi-generator
Stars: ✭ 73 (+305.56%)
Mutual labels:  openapi, openapi3
openapi-filter
Filter internal paths, operations, parameters, schemas etc from OpenAPI/Swagger/AsyncAPI definitions
Stars: ✭ 112 (+522.22%)
Mutual labels:  openapi, openapi3
Flama
🔥 Fire up your API with this flamethrower
Stars: ✭ 161 (+794.44%)
Mutual labels:  dependency-injection, openapi
sanic-ext
Extended Sanic functionality
Stars: ✭ 26 (+44.44%)
Mutual labels:  dependency-injection, openapi
Loopback Next
LoopBack makes it easy to build modern API applications that require complex integrations.
Stars: ✭ 3,972 (+21966.67%)
Mutual labels:  dependency-injection, openapi
oaie-sketch
OpenAPI Visual Editor
Stars: ✭ 54 (+200%)
Mutual labels:  openapi, openapi3
Full Stack Fastapi Couchbase
Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
Stars: ✭ 243 (+1250%)
Mutual labels:  openapi, openapi3
aws2openapi
Amazon Web Services API description to OpenAPI 3.0 definition
Stars: ✭ 45 (+150%)
Mutual labels:  openapi, openapi3
Openapi Codegen
OpenAPI 3.0 CodeGen plus Node.js minus the Java and emojis
Stars: ✭ 224 (+1144.44%)
Mutual labels:  openapi, openapi3
Spot
Spot is a concise, developer-friendly way to describe your API contract.
Stars: ✭ 230 (+1177.78%)
Mutual labels:  openapi, openapi3
openapi-viewer
Browse and test a REST API described with the OpenAPI 3.0 Specification
Stars: ✭ 85 (+372.22%)
Mutual labels:  openapi, openapi3
openapi-eller
Generate OpenAPI v3 clients and servers from the command line
Stars: ✭ 19 (+5.56%)
Mutual labels:  openapi, openapi3

whook

Build strong and efficient REST web services.

GitHub license Coverage Status

Why write code when you have an OpenAPI 3 definition?

Summary

Whook eats your documentation and provide you with a performant router that take care of running the right code for the right operation.

By using the OpenAPI standard and the dependency injection pattern, Whook provides a convenient, highly modular and easily testable back end framework.

Quickstart

To start a new Whook project:

# Initialize the project
npm init @whook;
cd my_project_name;

# Check install with a dry run of the server
DRY_RUN=1 npm run start

# Run tests
npm t

# Build the project
npm run build

# Create a new handler/service/provider
npx whook create

Why use Whook?

  • robust: types, functional programming
  • highly modular, extendable and reusable
  • fully integrated and production ready
  • easy to deploy, anywhere (serverless, docker, microservices): enter the anylith era
  • easy to test: TDD, E2E tests made easy
  • feature complete for most API use cases
  • simplify your life but embrace projects complexity

Usage

A tutorial is still to be written, expect it to come very soon. The above quickstart command is a good starting point.

That said you can check the following "How to" PRs:

Also, the packages/ folder contains a lot of easy to setup modules with well detailed readmes and setup instructions.

Finally, search for Whook's package easily with the NPM's Whook tag.

If you have any question or issue using Whook, post your help request to stack overflow with the Whook tag. Questions with this tag will be regularly checked by Whook's authors.

Finally, if you encounter any bug (unexpecter error, feature requests, OpenAPI specification violation), please fill an issue!

Principles

Check this deck for a complete introduction to Whook's principles!

Global overview

This projects aims to make creating well documented and highly customizable REST APIs a breeze. It is the final outcome of my experience building REST APIs with NodeJS.

By relying on the OpenAPI format to declare a new endpoint, this project forces documentation before code. It also is highly customizable since based on the dependency injection with inversion of control pattern allowing you to override or wrap its main constituents.

Architecture Overview

The Whook route handling flow is very simple.

First, we have a HTTPServer that handles requests an serve responses (the httpServer service).

Then, the httpTransaction transform the NodeJS requests into raw serializable ones (raw objects with no methods nor internal states).

Then the router (httpRouter) deal with that request to test which handler need to be run by comparing the method/path couple with the OpenAPI operations declarations.

Once found, it simply runs the right handler with the OpenAPI parameters value filled from the serializable request. The handler simply have to return a serializable response object in turn.

If any error occurs within this process, than the errorHandler is responsible for providing the now lacking response object based on the error it catches.

And that's it, you have your REST API. We have no middleware concept here. Instead, every handler is a simple function taking an object and returning another one. It makes those objects very easily composable (in a functional programming sense).

You may add global wrappers to change every handlers input/output on the fly or add a local wrapper specifically to one of a few handlers.

Core concepts

Whook work by adding ingredients to you API:

  • configuration: Whook look ups for config/{NODE_ENV}/config.js files. It creates constants you can inject in your handlers and services.
  • API: It defines the various endpoint of you API and how to map these to handlers thanks to the well known OpenAPI format (formerly Swagger),
  • handlers: the code that implement the API endpoints,
  • services: various services that deal with side effects,
  • wrappers: higher order functions you can apply to handlers (CORS authentication...).

You can see a lot of those concepts implemented in the Whook example folder.

Whook's DI system relies on the Knifecyle module. It is great for adding or easily override/wrap a lot of its core component and brings instrumentation and testability to your code bases.

Contributing

Contributors are very welcome to help pushing Whook forward!

Clone this project's repository and run:

npm it

The repository is based on LernaJS that allows to host several NPM packages in a single repository. That said, to keep it simple it only proxies the packages commands.

Install those VSCode extensions to get a smooth developer experience.

Publishing

NODE_ENV=cli npm run lerna  -- publish

Authors

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].