-
products folder should include Express server, grpc_product server and client, grpc_user client, product.proto and user.proto and tests for them.
-
users folder should include grpc_user server and user.proto.
-
Blackfriday, return the product list with 10% discount.
-
Birthday, return the product list with 5% discount.
-
When not 1. and 2, return the product list.
-
Without Connection for users gRPC server, return the product list
-
Separate gRPC server for products and users
-
Use /product end point.
$bash ./install.sh
-
$cd users && yarn serve
-
$cd ../products && yarn serve
in another console -
$yarn test-tape
in the same folder
It only use /product Express route with gRPC clients and Postgresql database.
- users
CREATE TABLE users(
id VARCHAR(255) PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
date_of_birth Date NOT NULL
);
- products
CREATE DOMAIN pct AS
REAL NOT NULL CHECK (value >= 0);
CREATE DOMAIN value_in_cents AS
INTEGER NOT NULL CHECK (value >= 0);
CREATE TYPE discount AS (
pct pct,
value_in_cents value_in_cents
);
CREATE TABLE products(
id VARCHAR(255) PRIMARY KEY,
price_in_cents INTEGER NOT NULL CHECK (price_in_cents > 0),
title VARCHAR(255) NOT NULL UNIQUE,
description TEXT NOT NULL,
discount discount
);
-
You can test them for users and products without datbase in before/without_db folders.
-
Then, you can modify them to be usable with database.
This is the mirror project of Graphql-Express-Postgresql. That means you can learn Graphql and gRPC with these projects.