# @energyweb/origin-backend

> API for managing users, certificate, requests and devices in the Origin project

Latest version **11.2.3** (published 2022-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @energyweb/origin-backend
pnpm add @energyweb/origin-backend
yarn add @energyweb/origin-backend
bun add @energyweb/origin-backend
```

Provides the commands `origin-backend`, `origin-backend-migrate`.

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 11.2.3 |
| Published | 2022-03-16 |
| First published | 2019-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 28 |
| Unpacked size | 598.5 KB |
| Known vulnerabilities | 0 (+27 in 10 direct dependencies) |
| Install scripts | no |
| GitHub stars | 110 |
| Author | EnergyWeb DevHub GmbH; Joseph Bagaric, joseph.bagaric@energyweb.org; Piotr Kosinski, piotr.kosinski@energyweb.org |
| Maintainers | kyleiankian, energywebdev, aznagy, bagaric, pkosin, drgorb, kroy, manihagh |

## Links

- npm: https://www.npmjs.com/package/@energyweb/origin-backend
- Repository: https://github.com/energywebfoundation/origin
- Homepage: https://github.com/energywebfoundation/origin/tree/master/packages/origin-backend#readme
- Issues: https://github.com/energywebfoundation/origin/issues
- npm.io page: https://npm.io/package/@energyweb/origin-backend

## Dependencies (28)

- [rxjs](https://npm.io/package/rxjs.md) 7.4.0
- [uuid](https://npm.io/package/uuid.md) 8.3.2
- [dotenv](https://npm.io/package/dotenv.md) 10.0.0
- [ethers](https://npm.io/package/ethers.md) 5.3.1
- [moment](https://npm.io/package/moment.md) 2.29.1
- [multer](https://npm.io/package/multer.md) 1.4.4
- [express](https://npm.io/package/express.md) 4.17.2
- [typeorm](https://npm.io/package/typeorm.md) 0.2.41
- [bcryptjs](https://npm.io/package/bcryptjs.md) 2.4.3
- [passport](https://npm.io/package/passport.md) 0.5.2
- [@nestjs/jwt](https://npm.io/package/@nestjs/jwt.md) 8.0.0
- [body-parser](https://npm.io/package/body-parser.md) 1.19.1
- [@nestjs/core](https://npm.io/package/@nestjs/core.md) 8.1.1
- [@nestjs/cqrs](https://npm.io/package/@nestjs/cqrs.md) 8.0.0
- [passport-jwt](https://npm.io/package/passport-jwt.md) 4.0.0
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) 8.1.1
- [@nestjs/config](https://npm.io/package/@nestjs/config.md) 1.0.2
- [passport-local](https://npm.io/package/passport-local.md) 1.0.0
- [@nestjs/swagger](https://npm.io/package/@nestjs/swagger.md) 5.1.4
- [@nestjs/typeorm](https://npm.io/package/@nestjs/typeorm.md) 8.0.2
- [class-validator](https://npm.io/package/class-validator.md) 0.13.2
- [@nestjs/passport](https://npm.io/package/@nestjs/passport.md) 8.0.1
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) 0.1.13
- [class-transformer](https://npm.io/package/class-transformer.md) 0.3.1
- [@energyweb/utils-general](https://npm.io/package/@energyweb/utils-general.md) 11.2.3
- [@nestjs/platform-express](https://npm.io/package/@nestjs/platform-express.md) 8.1.1
- [@energyweb/origin-backend-core](https://npm.io/package/@energyweb/origin-backend-core.md) 8.2.3
- [@energyweb/origin-backend-utils](https://npm.io/package/@energyweb/origin-backend-utils.md) 1.8.3

## Recent versions

- 11.2.3 (latest) — 2022-03-16
- 11.2.2-alpha.1658756736.0 (canary) — 2022-07-25
- 4.0.1-preview.4091.0 (preview) — 2020-03-16
- 11.2.2-alpha.1658745615.0 — 2022-07-25
- 11.2.2-alpha.1657642980.0 — 2022-07-12
- 11.2.2-alpha.1654697952.0 — 2022-06-08
- 11.2.2-alpha.1651489311.0 — 2022-05-02
- 11.2.2-alpha.1651149594.0 — 2022-04-28
- 11.2.4-alpha.1650636678.0 — 2022-04-22
- 11.2.2 — 2022-03-15
- 11.2.2-alpha.1646656455.0 — 2022-03-07
- 11.2.2-alpha.1646058469.0 — 2022-02-28
- 11.2.2-alpha.1646056819.0 — 2022-02-28
- 11.2.1 — 2022-01-18
- 11.2.1-alpha.1642431088.0 — 2022-01-17
- … 1666 more at https://npm.io/package/@energyweb/origin-backend/versions

## README

<p align="center">
  <a href="https://www.energyweb.org" target="blank"><img src="../../docs/images/EW.png" width="120" alt="Energy Web Foundation Logo" /></a>
</p>

# Origin Backend

The Origin Backend is a [NestJS](https://nestjs.com/) application that provides services for user and organization authorization and management. The Backend application can be used in conjunction with one, several or all of the [Origin SDKs](https://energy-web-foundation-origin.readthedocs-hosted.com/en/latest/) to provide integrated user management and authorization.

## Development

Origin-backend project is currently not meant to be run as a separate nest application. In order to run origin-backend project please refer to https://github.com/energywebfoundation/origin/tree/master/packages/origin-backend-app

Default TypeOrm configuration requires running PostgreSQL database. The detailed config with .env parameters is:

```
DB_HOST      - default 'localhost'
DB_PORT      - default 5432
DB_USERNAME  - default 'postgres',
DB_PASSWORD  - default 'postgres',
DB_DATABASE  - default 'origin',
```

or

```
DATABASE_URL  - postgres://{user}:{password}@{host}:{port}/{database}
```

### Using TypeORM migrations

Exchange project uses TypeORM mechanism to perform SQL data migrations. For detailed information please refer to https://github.com/typeorm/typeorm/blob/master/docs/migrations.md

-   `yarn typeorm:run` to update DB to latest exchange tables schema
-   `yarn typeorm:migrate SampleMigrationName` to create new migration file based on the changes in the code entities

Development flow:

-   run `yarn typeorm:run` - to apply latest migrations
-   apply changes in the entities, like change the variable name or type
-   run `yarn typeorm:migrate LastestChanges...`
-   inspect newly created migration in /migrations folder
-   run `yarn typeorm:run` to apply newly created migration

**Warning:**

**Existing migration files from `/migration` folder should never be edited after being committed.**

### PostgreSQL installation using Docker

```
docker pull postgres
docker run --name origin-postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres
```

#### pgAdmin

```
docker pull dpage/pgadmin4
docker run -p 80:80 \
    -e 'PGADMIN_DEFAULT_EMAIL=user@domain.com' \
    -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' \
    -d dpage/pgadmin4
```

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