$ npm i git@github.com:avensia/api-sample-server.git --save
$ node_modules/.bin/api-server
# Or run `api-server` in run-script, e.g:
# ...
# "scripts": {
# "start": "api-server | webpack"
# }
# ...
$ npm start
Then the server is running on the default port, 8181
. You can change the port with the environment variable SERVER_PORT
.
$ SERVER_PORT=8282 node_modules/.bin/api-server
No parameters
Responds with an Array
containing all products.
No parameters
Responds with product identified with the given :id
.
No parameters
Responds with full cart. Cart items and summary.
No parameters
Empty cart. Responds with full updated cart.
Parameters: quantity=[number]
Add quantity
to item with product identified with :id
. Responds with full updated cart.
Parameters: quantity=[number]
Update quantity
to item with product identified with :id
. If item doesn't exist in cart, it will be added with the given quantity
. Responds with full updated cart.
No parameters
Remove item with :id
. Responds with full updated cart.
type Product = {
id: number;
title: string;
imageUrl: string;
url: string; // Absolute URL to API
prices: Price[];
};
type Price = {
amount: number;
currency: string; // Currently SEK and EUR
};
type Cart = {
items: Item[];
summary: Price[];
}
type Item = {
product: Product;
quantity: number;
};