# glia

> Lightweight Microservice Framework

Latest version **0.0.45** (published 2020-08-10) · 0 weekly downloads

## Install

```sh
npm install glia
pnpm add glia
yarn add glia
bun add glia
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.45 |
| Published | 2020-08-10 |
| First published | 2020-05-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 23.9 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | Jack Milles |
| Maintainers | jack_milles |
| Keywords | glia, microservice, routing, validation, sanitization, service, model, express |

## Links

- npm: https://www.npmjs.com/package/glia
- Homepage: https://github.com/somatyjack/glia
- npm.io page: https://npm.io/package/glia

## Dependencies (5)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [express](https://npm.io/package/express.md) ^4.17.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.5

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.0.45 (latest) — 2020-08-10
- 0.0.44 — 2020-08-09
- 0.0.43 — 2020-07-29
- 0.0.42 — 2020-07-18
- 0.0.41 — 2020-07-18
- 0.0.40 — 2020-07-16
- 0.0.39 — 2020-07-16
- 0.0.38 — 2020-07-16
- 0.0.37 — 2020-07-16
- 0.0.36 — 2020-07-06
- 0.0.35 — 2020-06-01
- 0.0.34 — 2020-05-28
- 0.0.33 — 2020-05-19
- 0.0.31 — 2020-05-16
- 0.0.30 — 2020-05-16
- … 18 more at https://npm.io/package/glia/versions

## README

# Glia

Lightweight Microservice Framework

[![npm (scoped)](https://img.shields.io/npm/v/glia)](https://github.com/somatyjack/glia)

[![codecov](https://codecov.io/gh/somatyjack/glia/branch/master/graph/badge.svg)](https://codecov.io/gh/somatyjack/glia)

## lets see how far I can make it

<img width="531" alt="Glia-diagram" src="https://user-images.githubusercontent.com/10210303/82105252-44efe780-9712-11ea-83e1-a32d039c62e6.png">

> 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

```JavaScript
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

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

### Define model - ( RAW || Sequelizer )

> Raw MySQL access example

```JavaScript
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

<!--
# What do you want to see as a next feature:

/polls "Error extension" 'Option 2' "Option 3"

[![](https://api.gh-polls.com/poll/01BY7ECS60GG8F9AR1VMR8745S/Error%20extension)](https://api.gh-polls.com/poll/01BY7ECS60GG8F9AR1VMR8745S/Error%20extension/vote)
[![](https://api.gh-polls.com/poll/01BY7ECS60GG8F9AR1VMR8745S/Option%202)](https://api.gh-polls.com/poll/01BY7ECS60GG8F9AR1VMR8745S/Option%202/vote)
[![](https://api.gh-polls.com/poll/01BY7ECS60GG8F9AR1VMR8745S/Option%203)](https://api.gh-polls.com/poll/01BY7ECS60GG8F9AR1VMR8745S/Option%203/vote)
-->

---
_Source: https://npm.io/package/glia · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
