Skip to content

ardguezsoc/karma-mongo2postgres

 
 

Repository files navigation

karma-mongo2postgres

COMPONENTS

Stored into the /components folder. Each one of them comes with an index.js file that acts as a manifest telling systemic how to wire components but most important in which order starting and stopping them.

Hierarchy

  • app: karma-mongo2postgres root system (component).
  • logger: logging utility component.
  • express: express server component.
  • config: configuration manager component.
  • routes: express server routes component.
    • routes.admin: admin api routes sub-components.

app

The root component defining the service system.

logger

The logging component providing the following logs structure:

{TIMESTAMP} | {LOG_LEVEL} [{karma-mongo2postgres}] | {MESSAGE}

express

An express server that always comes in handy to expose at least a set of admin endpoints for monitoring purposes.

config

The component in charge of mixing and set up the configuration defined into the files of the folder /config in order to come up with the correct configuration for the given run mode:

  • default
  • local
  • test
  • build
  • prod

routes

The component in charge of specifiyng the routes to be exposed by the express component. Note that the express endpoints are secured thanks to helmet.

routes.admin

The admin api sub-component in charge of exposing the /__/manifest endpoint.

CONFIG

The configuration is scattered across different files and mixed according to the service run mode as said above. The intesting bit is the fact that is stored in js objects and is definable per-component and per-sub-component.

E.g. routes and routes.admin default configuration:

{
    routes: {
		admin: {
			swaggerValidator: {
				apiDocEndpoint: '/__/docs/api',
				validateRequests: true,
				validateResponses: true,
				validationEndpoint: '/test',
				format: 'yaml',
				yaml: {
					file: './docs/syncapi.yaml',
				},
			},
		},
    },
}

DOCS

The /docs folder holds the synchronous api documentation for the endpoints exposed by the routes component. As defined in the above section the syncapi.yaml is used by the swagger-endpoint-validator in order to:

  • validate the requests and responses.
  • expose the swagger api documentation at the /__/docs/api endpoint.

DOCKER

  • Dokcerfile: the service is dockerized and ready to be shipped thanks to the Dockerfile.

MAKE

The service comes whit an easy and lean makefile that can be used as a base for any CI/CD tool that need to manage the service.

START

Starting the service means to start the system components and sub-components in the proper order. Something that the index.js and the system.js files are taking care of.

npm run start

TEST

The service comes with a simple tests framework already in place in the /test folder.

running the tests

npm run test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 91.3%
  • PLpgSQL 5.8%
  • Makefile 1.9%
  • Dockerfile 1.0%