service-cruddata-node
v1.0.0
Published
This is a CRUD Data microservice that stores and retrieves entities and exposes a regular CRUD interface.
Downloads
2
Readme
CRUD Data microservice in Node.js
This is a CRUD Data microservice that stores and retrieves entities and exposes a regular CRUD interface.
Supported functionality:
- Deployment platforms: Standalone Process, Docker, AWS, GCP, Azure Cloud
- External APIs: Commandable HTTP, HTTP/REST, GRPC, Commandable GRPC
- Persistence: Memory, Flat Files, MongoDB
- Health checks: Heartbeat, Status
- Consolidated logging: ElasticSearch
- Consolidated metrics: Prometheus
- Swagger: http://localhost:8080/swagger/index.html
There are no dependencies on other microservices.
Quick links:
- Communication Protocols:
- Client Libraries:
- API Reference
- Change Log
- License
- ToDo List
- Usage Notes
Contract
class EntityTypeV1 {
public static Unknown: string = "unknown";
public static Type1: string = "type1";
public static Type2: string = "type2";
public static Type3: string = "type3";
}
class EntityV1 {
public id: string;
public site_id: string;
public type?: string;
public name?: string;
public content?: string;
}
export interface IEntitiesService {
getEntities(traceId: string, filter: FilterParams, paging: PagingParams): Promise<DataPage<EntityV1>>;
getEntityById(traceId: string, entityId: string): Promise<EntityV1>;
getEntityByName(traceId: string, entityId: string): Promise<EntityV1>;
createEntity(traceId: string, entity: EntityV1): Promise<EntityV1>;
updateEntity(traceId: string, entity: EntityV1): Promise<EntityV1>;
deleteEntityById(traceId: string, entityId: string): Promise<EntityV1>;
}
Get
Get the microservice source from BitBucket:
git clone [email protected]:entinco/eic-templates-services-node.git
cd service-cruddata-node
Get docker image for the microservice:
docker pull entinco/service-cruddata-node:latest
Run
The microservice can be configured using the environment variables:
- AZURE_ENABLED - turn on Azure container
- DATADOG_ENABLED - turn on DataDog loggers and metrics
- DATADOG_PROTOCOL - (optional) connection protocol: http or https (default: https)
- DATADOG_URI - (optional) resource URI or connection string with all parameters in it
- DATADOG_HOST - (optional) host name or IP address (default: api.datadoghq.com)
- DATADOG_PORT - (optional) port number (default: 443)
- DATADOG_ACCESS_KEY - DataDog client api key
- ELASTICSEARCH_LOGGING_ENABLED - turn on Elasticsearch logs and metrics
- ELASTICSEARCH_PROTOCOL - connection protocol: http or https
- ELASTICSEARCH_SERVICE_URI - resource URI or connection string with all parameters in it
- ELASTICSEARCH_SERVICE_HOST - host name or IP address
- ELASTICSEARCH_SERVICE_PORT - port number
- LAMBDA_ENABLED - turn on AWS lambda container
- MONGO_SERVICE_URI - URI to connect to MongoDB. When it's defined other database parameters are ignored
- MONGO_SERVICE_HOST - MongoDB hostname or server address
- MONGO_SERVICE_PORT - MongoDB port number (default: 3360)
- MONGO_DB - MongoDB database name (default: app)
- MONGO_COLLECTION - MongoDB collection (default: id_records)
- MONGO_USER - MongoDB user login
- MONGO_PASS - MongoDB user password
- GCP_ENABLED - turn on Google Cloud Function container
- GRPC_ENABLED - turn on GRPC endpoint
- GRPC_PORT - GRPC port number (default: 8090)
- HTTP_ENABLED - turn on HTTP endpoint
- HTTP_PORT - HTTP port number (default: 8080)
- PUSHGATEWAY_METRICS_ENABLED - turn on pushgetway for prometheus
- PUSHGATEWAY_PROTOCOL - connection protocol: http or https
- PUSHGATEWAY_METRICS_SERVICE_URI - resource URI or connection string with all parameters in it
- PUSHGATEWAY_METRICS_SERVICE_HOST - host name or IP address
- PUSHGATEWAY_METRICS_SERVICE_PORT - port number
- SWAGGER_ROUTE - the path where the swagger service will be available
- SWAGGER_NAME - the header name of swagger service
- SWAGGER_DESCRIPTION - the text description of swagger service
Start the microservice as a process:
node ./bin/main
Run the microservice in docker. Then use the following command:
./run.ps1
Launch the microservice with all infrastructure services using docker-compose:
docker-compose -f ./docker/docker-compose.yml up
Develop
For development, you will need to install the following prerequisites:
- Node.js 14+
- Visual Studio Code or another IDE of your choice
- Docker
Install dependencies:
npm install
Compile the microservice:
tsc
Compile proto files:
npm run protogen
Before running tests, launch the infrastructure services and required microservices:
docker-compose -f ./docker-compose.dev.yml up
Run automated tests:
npm test
Run automated benchmarks:
npm run benchmark
Run linter:
npm run lint
Generate API documentation:
./docgen.ps1
Before committing changes, run dockerized build and test as:
./build.ps1
./protogen.ps1
./test.ps1
./package.ps1
./run.ps1
./clean.ps1
Contacts
This microservice was created by and is currently maintained by Person Name.