glia

0.0.45 • Public • Published

Glia

Lightweight Microservice Framework

npm (scoped)

codecov

lets see how far I can make it

Glia-diagram

All you should care at the end of the day is your business logic

Getting started in 4 simple steps

Configure your service

Database
Paths for Logs/Validation/Sanitization/Configs (Althought default values are available)

Setup routing

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
}

Define service - Business Logic

all passed params will be available within data object

LoadTimeZones: async (data) => {
    let timeZones timeZones = await getModel.GetTimeZones(data);
    return timeZones;
}

Define model - ( RAW || Sequelizer )

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

Package Sidebar

Install

npm i glia

Weekly Downloads

1

Version

0.0.45

License

none

Unpacked Size

24.5 kB

Total Files

14

Last publish

Collaborators

  • jack_milles