Lightweight Microservice Framework
All you should care at the end of the day is your business logic
Database
Paths for Logs/Validation/Sanitization/Configs (Althought default values are available)
const timeZones = {
paramExpected: "", // param being passed with url
batch: "LoadTimeZones", // service function to be called
routeType: "internal", // how service is exposed internal || external
};
const routes = {
"/v1/time-zones": timeZones, // each endpoint can be versioned, by default all enpoints use v1
}
all passed params will be available within data object
LoadTimeZones: async (data) => {
let timeZones timeZones = await getModel.GetTimeZones(data);
return timeZones;
}
Raw MySQL access example
GetTimeZones: async function (data) {
const q = `SELECT * FROM time_zone WHERE active = 1`;
const conn = await getConnection();
const result = (await conn.query(q))[0];
conn.release();
if (result.length < 1)
throw new DbError(
"Time zone table does not contain any data",
"GetTimeZones"
);
return result;
}
List of features:
- Pure JavaScript control over the BusinessLogic - you get input and you return output
- DB Layer - Sequelizer, Raw Queries(to support what Sequelizer struggles to do)
- Custom sanitizer provider with an option to override
- @hapi/joi fields validator with an option to plug your own
- Nested error handling. Option to customize response override
- Easy service pathnames processing