-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mbaye THIAM
committed
Apr 15, 2024
1 parent
93a28b5
commit a03a267
Showing
26 changed files
with
3,312 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Run Integration Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
integration-tests: | ||
runs-on: ubuntu-latest | ||
services: | ||
registry: | ||
image: registry:2 | ||
ports: | ||
- 5000:5000 | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
driver-opts: network=host | ||
|
||
- name: Copy patches for Docker Buildx | ||
run: cp -r patches/* packages/graphql-mesh/patches | ||
|
||
- name: Build and push on local registry | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./packages/graphql-mesh | ||
push: true | ||
tags: localhost:5000/test/graphql-mesh:latest | ||
platforms: linux/amd64 | ||
|
||
- name: Setup services for testing purpose | ||
run: export IMAGE_TAG=localhost:5000/test/graphql-mesh:latest && cd ./test/integration && docker compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
# Use a base image with Node.js | ||
FROM node:18-alpine | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the code to the working directory | ||
COPY . . | ||
|
||
# Expose the port on which your API will run | ||
#EXPOSE 5000 | ||
|
||
# Define the command to start your API | ||
CMD ["npm", "run", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Products API | ||
description: API to manage products with HATEOAS. | ||
version: "1.0" | ||
servers: | ||
- url: http://localhost:3000/ | ||
paths: | ||
/products: | ||
get: | ||
operationId: getProducts | ||
summary: List all products | ||
responses: | ||
"200": | ||
description: A list of products with HATEOAS links | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Products" | ||
/products/{id}: | ||
get: | ||
operationId: getProductById | ||
summary: Get a product by ID | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
schema: | ||
type: integer | ||
description: The product ID | ||
responses: | ||
"200": | ||
description: A list of products with HATEOAS links | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Product" | ||
components: | ||
schemas: | ||
Product: | ||
type: object | ||
properties: | ||
_links: | ||
$ref: "#/components/schemas/ProductLinks" | ||
id: | ||
type: integer | ||
name: | ||
type: string | ||
price: | ||
type: number | ||
supplierId: | ||
type: integer | ||
ProductLinks: | ||
type: object | ||
required: | ||
- self | ||
- supplier | ||
properties: | ||
self: | ||
$ref: "#/components/schemas/Link" | ||
supplier: | ||
$ref: "#/components/schemas/Link" | ||
x-links: | ||
- rel: self | ||
hrefPattern: "/products/{id}" | ||
- rel: supplier | ||
hrefPattern: "/suppliers/{id}" | ||
|
||
Products: | ||
type: object | ||
properties: | ||
items: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/Product" | ||
Link: | ||
type: object | ||
required: | ||
- href | ||
properties: | ||
href: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Suppliers API | ||
description: API to manage suppliers with HATEOAS. | ||
version: "1.0" | ||
servers: | ||
- url: http://localhost:3000/ | ||
paths: | ||
/suppliers: | ||
get: | ||
operationId: getSuppliers | ||
summary: List all suppliers | ||
responses: | ||
"200": | ||
description: A list of suppliers with HATEOAS links | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Suppliers" | ||
/suppliers/{id}: | ||
get: | ||
operationId: getSupplierById | ||
summary: Get a supplier by ID | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
schema: | ||
type: integer | ||
description: The supplier ID | ||
responses: | ||
"200": | ||
description: A list of suppliers with HATEOAS links | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Supplier" | ||
components: | ||
schemas: | ||
Supplier: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
name: | ||
type: string | ||
Link: | ||
type: object | ||
required: | ||
- href | ||
properties: | ||
href: | ||
type: string | ||
Suppliers: | ||
type: object | ||
properties: | ||
items: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/Supplier" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
type Product = { | ||
id: number | ||
name: string | ||
price: number | ||
supplierId: number | ||
_links: { | ||
supplier: { | ||
href: string | ||
} | ||
self?: { | ||
href: string | ||
} | ||
} | ||
} | ||
|
||
function generateProducts() { | ||
const _products: Product[] = [] | ||
for (let i = 1; i <= 50; i++) { | ||
const supplierId = Math.floor(Math.random() * 10) + 1 | ||
const product: Product = { | ||
id: i, | ||
name: `Product ${i}`, | ||
price: Math.floor(Math.random() * 100), | ||
supplierId, | ||
_links: { | ||
self: { | ||
href: `/products/${i}` | ||
}, | ||
supplier: { | ||
href: `/suppliers/${supplierId}` | ||
} | ||
} | ||
} | ||
_products.push(product) | ||
} | ||
return _products | ||
} | ||
|
||
export const products = generateProducts() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type Supplier = { | ||
id: number | ||
name: string | ||
} | ||
|
||
const generateSuppliers = () => { | ||
const _suppliers: Supplier[] = [] | ||
for (let i = 1; i <= 10; i++) { | ||
const supplier: Supplier = { | ||
id: i, | ||
name: `Supplier ${i}` | ||
} | ||
_suppliers.push(supplier) | ||
} | ||
return _suppliers | ||
} | ||
|
||
export const suppliers = generateSuppliers() |
Oops, something went wrong.