@dotslibrary/dots-core v0.6.19
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 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago