# tayeh-env

> Tayeh config module

Latest version **0.0.21** (published 2023-08-08) · UNLICENCED license · 0 weekly downloads

## Install

```sh
npm install tayeh-env
pnpm add tayeh-env
yarn add tayeh-env
bun add tayeh-env
```

## Health

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

Positive: has types; no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.21 |
| Published | 2023-08-08 |
| First published | 2023-08-08 |
| Weekly downloads | 0 |
| License | UNLICENCED |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 61.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aref Akbari |
| Maintainers | arefakbariatwork |
| Keywords | Tayeh, Config, env |

## Links

- npm: https://www.npmjs.com/package/tayeh-env
- Repository: git@git.pchas.ir:tayeh-private/tayeh-env
- npm.io page: https://npm.io/package/tayeh-env

## Dependencies (1)

- [dotenv](https://npm.io/package/dotenv.md) *

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 0.0.21 (latest) — 2023-08-08

## README

# Tayeh Es

Tayeh Project Event sourcing module 
<br></br>

## Setup   

1- First install mariadb on master, open my.cnf and add following

    [mariadb]
	log-bin
	server_id=1
	log-basename=master1
	binlog-format=mixed

	skip_networking=0
	bind_address=


2- Then create replication user

```sql
	CREATE USER 'replication_user'@'%' IDENTIFIED BY 'password';
	GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%';
```

3- Next We Should start slave servers, add server ids

	[mariadb]
	server_id=2

4- Backup Master

	mysqldump -u user events -p > backup.sql

5- Import backup in slaves

	mysql -u user events -p < backup.sql

6- Set master domain in slaves (only networked are allowed), add line below in hosts

	xx.xx.xx.xx	db.master

7- Start Slaves	
```ts
	CHANGE MASTER TO
	 MASTER_USE_GTID = slave_pos
	 MASTER_HOST='master.domain.com',
	 MASTER_USER='replication_user',
	 MASTER_PASSWORD='password',
	 MASTER_PORT=3306,
	 MASTER_CONNECT_RETRY=10;

	STOP SLAVE SQL_THREAD;
	SET GLOBAL slave_parallel_threads = 4;
	START SLAVE SQL_THREAD;
	SELECT @@slave_parallel_threads;

	 START SLAVE;
	 SHOW SLAVE STATUS;
```
</br>
</br>

## Usage 

Import module in project 

```ts
	TayehEsModule.forRoot({
		username: 'user';
		password: 'pass';
		host: 'localhost';
		connectionLimit: 2;
	})
```  

Use it like this

```ts
es.write(
	ESEventType.User, // event type
	1, // entity id
	{example: true}, // data
	creator: 1, // creator id
	1 // cause id
) 
// Or multiple writes with batchWrite
```

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