1.3.7 • Published 2 years ago

elzeard v1.3.7

Weekly downloads
4
License
ISC
Repository
github
Last release
2 years ago

OOP Data Manager based on Knex and Joi. 🌿

Introduction

Elzeard is a OOP data manager built on top of Knex, and Joi : Two main JS libraries when it's about maintaining code organization and securizing back-end apps.

⚠️ The current version only works with a MySQL/Maria database

1. Quick intro with Knex : SQL query builder

Building SQL queries is an annoying and redundant task. Knex answers to that problem by greatly symplifying the query building process:

Without it:

select * from `users` where `id` = 1

With it:

knex('users').where('id', 1)

2. Quick intro with Joi : Schema descriptor and data validator

  • Data formating + treating
  • Rendering errors when needed (ex: POST/PUT req in an API)
  • Defining Model schema

are also an annoying and redundant task.

With Joi, you can define a schema and generate well-transcripted errors when a data doesn't match its model.

Example:

const schema = Joi.object({
    username: Joi.string().alphanum().min(3).max(30).required(),
    password: Joi.string().pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
    access_token: Joi.token()
    birth_year: Joi.number().integer().min(1900).max(2013),
    email: Joi.string().email()
})

schema.validate({ username: 'abc', birth_year: 1994 });
// -> { value: { username: 'abc', birth_year: 1994 } }

schema.validate({});
// -> { value: {}, error: '"username" is required' }

3. Quick intro with Joi x SQL : Combination of both integrated in Elzeard

Table and column management when iterating on a back-end application is an everyday task that can be removed with automation. We did it, and it is one of the main feature of Elzeard.

Quick example here

Get Started

Usage

yarn add elzeard

After all your collections have been instanced, set your configuration and make it 'done':

import { config } from 'elzeard'
import MyCollection1 from './my-collection-1'
import MyCollection2 from './my-collection-2'
import { startServer } from './server'
...

const myCollect1 = new MyCollection1([], {table: 'collection-1'})
const myCollect2 = new MyCollection2([], {table: 'collection-2'})
...

const initConfig = async () => {
  await config.done()
  ...
}

initConfig()
startServer()
1.3.7

2 years ago

1.2.8

2 years ago

1.3.6

2 years ago

1.2.7

2 years ago

1.3.5

2 years ago

1.2.6

2 years ago

1.3.4

2 years ago

1.2.5

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago