1.10.0 • Published 7 months ago

ambisis_node_helper v1.10.0

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

ambisis_node_helper

service integrator

Use it to comunicate with other services using private or public keys

import { ServiceIntegrator } from 'ambisis_node_helper';

const { integration } = EnvironmentSettings.instance;

export const mailServiceIntegrator = new ServiceIntegrator({
	serviceHost: "localhost:3035",
	privateKey: "12345",
});

await mailServiceIntegrator.post('/daily_report', {
	foo: 'foo'
});

response = await mailServiceIntegrator.get('/foo?bar=123')

response.status

body = response.json()
console.log(body)
{
	"code": 200,
	"message": "SUCCESS"
}

validate_format

import { Application } from 'express';
import { body } from 'express-validator';
import { root } from '../../controllers/daily_report/POST';
import { validate_format } from 'ambisis_node_helper';

export default (app: Application) => {
	app.post(
		'/foo',
		body('foo').isString().notEmpty(),
		body('bar').isString().notEmpty(),
		validate_format,
		root
	);
};

middleware package

import { Application } from 'express';
import { ambisisMiddlewarePackage } from 'ambisis_node_helper';

export default (app: Application) => {
	ambisisMiddlewarePackage(app, {
		privateKey: "12345",
		
	});
};

Ambisis response

// Non error, without data
return ambisisResponse(res, 200, 'SUCCESS');
{
	"code": 200,
	"error": "SUCCESS"
}


// Non error, with data
return ambisisResponse(res, 200, 'SUCCESS', {id: 123});
{
	"code": 200,
	"error": "SUCCESS",
	"data": {id: 123}
}

// Error
return ambisisResponse(res, 400, 'BAD_REQUEST');
{
	"code": 400,
	"error": "BAD_REQUEST"
}


// Error with data
return ambisisResponse(res, 422, 'BAD_REQUEST', {reason: "because you are dumb"});
{
	"code": 422,
	"error": "BAD_REQUEST",
	"data": {reason: "because you are dumb"}
}
1.9.0

7 months ago

1.10.0

7 months ago

1.8.0

11 months ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.0

2 years ago

1.5.1

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.10

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago