Skip to content

Antman261/http-schemas-webserver-demo

Repository files navigation

HTTP-Schemas Webserver Demo

This repository serves as a demonstration of the http-schemas library in a production-like web application.

It demonstrates:

  • Creating a pseudo-monorepo containing client, server, and shared schema
  • Defining a well typed API schema with input and output types.
  • Well separated route logic from domain logic
  • How good type definition flows down to robustly typed persistence layers and back.
  • Build and development processes
  • Well typed client code and logic utilising the types provided from the API schema

Getting started

First clone the repo:

git clone https://github.com/Antman261/http-schemas-webserver-demo.git

then run the bootstrap script to install all dependencies:

cd http-schemas-webserver-demo
npm run bootstrap

To start all repos in watch mode:

npm run start

This will start the local client on port 3000 and the API on port 8080. This lets you use create-react-app's hot-reloading development server while working on the client.

To serve the client from the webserver, run npm run build inside the client directory. This will place a production build of the client in server/build/client for the webserver to serve.

Understanding http-schemas

http-schemas provides a shared definition for a well-typed API. By providing strong typing and run time validation at the most crucial boundary of any web service, http-schemas makes your applications much more robust.

Your entire application code becomes much easier to type and reason about when your API boundary is typed.

For more information, read the readme in:

  1. shared/http
  2. server
  3. client

for the best introduction to http-schemas.

About

A demonstration of the http-schemas package in a full application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published