1.0.4 • Published 9 months ago

@dotslibrary/dots-core v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Dots-Core

Fast, scalable which supports http & event driven communication build on top of express node.

Installation

This is a Node.js module available through the private npm registry.

Before installing, download and install Node.js. Node.js 12 or higher is required.

Installation is done using the npm install command:

$ npm install @dotslibrary/dots-core

Inside the modules create a file called index.js:

import { app, applicationBootstrap } from 'woz-lib'

import { user } from './user/user.controller'

app.use(user.router)

applicationBootstrap(app, {
    MONGO_DB_URL: process.env.MONGO_DB,
    RABBIT_MQ_URL: process.env.RABBIT_MQ,
}).then(() => {
    const queue = MESSAGE_QUEUE.SMS_OTP

    subscribe(queue, msg => {
        console.log(queue, msg)
    })
    publish(queue, msg => {
        console.log(queue, msg)
    })
})

subscribe & publish methods are bulid on top of RabbitMq, it handles all the complexity of queues.

subscribe method listens on a given queue and executes registered callback function.

publish method emits message on a given queue.

Environments directory contains different env profiles

Start application using one of the below command Consumes env variables from environments/dev.env

npm run start:dev

Consumes env variables from environments/prod.env

npm run start:prod

Consumes env variables from environments/test.env

npm run start:test

Below are mandatory env variables

NODE_ENV = test
PORT = 7000
MONGO_DB = 'mongodb://localhost/my_database'
RABBIT_MQ = 'amqp://userData:passwordData1@localhost'

Features

  • Robust routing
  • Focus on high performance
  • Super-high test coverage
  • HTTP helpers (redirection, caching, etc)
  • message queue handler
  • View system supporting 14+ template engines
  • Exception handler
  • Executable for generating applications quickly

Project setup

$ git checkout intro/mock-application && npm install

Business logic blocks should be under modules directory, follow the structure of users under modules.

  • Controller contains application routes, request validation and should contain only single method from the service.
  • Model has business logic data points.
  • Repository consists methods which are used to retrieve data from db.
  • Util add helper function to service layer.
  • Service layer combines response of from repository & util.
  • DTO consists data points from the request.
  • Interface consists types I/O of methods.
├── tsconfig.json
├── npmrc
├── prettierignore
├── prettierrc
├── eslintrc
├── eslintignore
├── gitignore
├── package.json
├── environments
│         ├── dev.env
│         ├── prod.env
│         └── test.env
│
└── modules
      ├── index.ts
      └── users
           ├── user.controller.ts
           ├── user.model.ts
           ├── user.util.ts
           ├── user.repository.ts
           ├── user.dto.ts
           ├── user.interface.ts
           └── user.service.ts

Entry file index.ts wraps all the routers and bootstraps application in @dotslibrary/dots-core.

Follow the mock application from intro/mock-application as sample project using @dotslibrary/dots-core

1.0.2

9 months ago

0.6.21

9 months ago

1.0.1

9 months ago

0.6.20

9 months ago

1.0.0

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

0.6.18

3 years ago

0.6.19

3 years ago

0.6.17

3 years ago

0.6.14

3 years ago

0.6.16

3 years ago

0.6.15

3 years ago

0.6.15-t4

3 years ago

0.6.15-t1

3 years ago

0.6.15-t2

3 years ago

0.6.15-t

3 years ago

0.6.9

3 years ago

0.6.8

3 years ago

0.6.10

3 years ago

0.6.12

3 years ago

0.6.11

3 years ago

0.6.13

3 years ago

0.6.7

3 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago