Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raferdev/express_microservice
Here you will see a microservice project that includes complete support for development.
https://github.com/raferdev/express_microservice
aws aws-lambda dynamodb express jest microservice opentelemetry serverless test
Last synced: about 2 months ago
JSON representation
Here you will see a microservice project that includes complete support for development.
- Host: GitHub
- URL: https://github.com/raferdev/express_microservice
- Owner: raferdev
- Archived: true
- Created: 2024-04-19T23:42:02.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-24T19:49:26.000Z (7 months ago)
- Last Synced: 2024-09-21T11:02:42.045Z (about 2 months ago)
- Topics: aws, aws-lambda, dynamodb, express, jest, microservice, opentelemetry, serverless, test
- Language: TypeScript
- Homepage:
- Size: 308 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CUSTOMERS MICROSERVICE REST API
[![Test amd Deploy](https://github.com/raferdev/express_microservice/actions/workflows/deploy.yml/badge.svg)](https://github.com/raferdev/express_microservice/actions/workflows/deploy.yml)
This is a microservice builded with serverless framework.
This project contains:
- CI/CD : Using Github Actions to automate tests with Jest and deploy serverless insfrastructure on AWS cloud
- Logs/Metrics/Control : Environment instrumentalized with open-telemetry Node, Express, and Winston, being captured by AWS observability.
- Architecture: Built across Express routes, middlewares, controllers, and services, it can handle and control all endpoints using AWS Lambda and persist on DynamoDB.
- Linting: Eslint with flat config, prettier, lint-staged with husly.
Table of Content:
- 1.0 - [Installation](#install)
- 2.0 - [Running](#run)
- 2.1 - [Tests](#run-tests)
- 3.0 - [API REST](#api-rest)## [Install](#install)
pnpm install
## [Run the app](#run)
You need first create dynamoDB table in AWS with the name "customers-microservice-$stage"
$stage is the stage that you will pass on initial scriptlike:
- serverless offline --stage development
## [Run the tests](#run-tests)
pnpm test
# [REST API](#api-rest)
The REST API to the example app is described below.
## Get list of Things
### Request
`GET /v1/customers`
curl -i -X GET'Accept: application/json' http://localhost:3000/v1/customers
### Response
HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 2[]
## Create a new customer
### Request
`PUT /v1/customers`
curl -i -X PUT 'Accept: application/json' -d 'name=Foo&email=new@new&phone=+553488383584&addess=exemple' http://localhost:3000/v1/customers
### Response
HTTP/1.1 201 Created
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 201 Created
Connection: close
Content-Type: application/json
Location: /thing/1
Content-Length: 36{ "customersID":$UUID,
"name":"Foo",
"email":"new@new",
"phone":"+553488383584",
"address":"exemple city"}## Get a specific customer
### Request
`GET /v1/customers/:customerID`
curl -i -H 'Accept: application/json' http://localhost:3000/v1/customers/:customerID
### Response
HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 36{ "customerID":$UUID,
"name":"Foo",
"email":"new@new",
"phone":"+553488383584",
"address":"exemple city"}## Delete customer
### Request
`DELETE /v1/customers/:customersID`
curl -i -H 'Accept: application/json' http://localhost:3000/v1/customers/:customersID
### Response
HTTP/1.1 200 Success
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 404 Not Found
Connection: close
Content-Type: application/json
Content-Length: 35{}
## Search by text
### Request
`GET /v1/search`
curl -i -H 'Accept: application/json' -d 'name=Bar&junk=rubbish' http://localhost:3000/v1/search?text=exemple%text
### Response
HTTP/1.1 200 Success
Date: Thu, 24 Feb 2011 12:36:31 GMT
Status: 200 Success
Connection: close
Content-Type: application/json
Location: /thing/2
Content-Length: 35[{ "customerID":$UUID,
"name":"Foo",
"email":"new@new",
"phone":"+553488383584",
"address":"exemple city"},... ]