npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@energyweb/origin-backend-app

v1.5.4

Published

This is a bootstrap project for Origin API

Downloads

1,650

Readme

Origin-Backend-App package provides is a runner for a nest.js application that consist of Origin-Backend and Exchange packages.

Development

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

yarn start to start the origin backend and exchange as one application Note: this will not run the migrations for origin-backend and exchange.

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}

Other configuration variables

PORT:                                           <PORT to which nest application start listening>
BACKEND_PORT:                                   <Same as PORT >
BACKEND_URL:                                    <URL on which this application will be available for e.g https://origin-api-canary.herokuapp.com>
BLOCKCHAIN_EXPLORER_URL:                        <For e.g for Volta network https://volta-rpc-origin-0a316ab339e3d2ee3.energyweb.org>
DEPLOY_KEY:                                     <Private key used for Issuer contracts deployment>
EMAIL_FROM:                                     <Email from for Mandrill API>
EMAIL_REPLY_TO:                                 <Email reply to for Mandrill API>
ENERGY_API_BASE_URL:                            <URL for Energy API>
EXCHANGE_ACCOUNT_DEPLOYER_PRIV:                 <Private key used for exchange accounts deployment>
EXCHANGE_WALLET_PRIV:                           <Private key for wallet used for withdrawals>
EXCHANGE_WALLET_PUB:                            <Address of the wallet defined in EXCHANGE_WALLET_PRIV>
ISSUER_ID:                                      <Name of the external device id type used in the issuance process for e.g Issuer ID>
JWT_EXPIRY_TIME:                                <Expiry time for e.g 7 days>
JWT_SECRET:                                     <Secret>
MANDRILL_API_KEY:                               <API KEY>
REGISTRATION_MESSAGE_TO_SIGN:                   <For e.g I register as Origin user>
UI_BASE_URL:                                    <URL on which UI is deployed for e.g https://origin-ui-canary.herokuapp.com/>
WEB3:                                           <WEB3 provider url>
MARKET_UTC_OFFSET:                              <UTC offset in minutes (-120, -60, 0, 60, etc)>

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 '[email protected]' \
    -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' \
    -d dpage/pgadmin4

Swagger

Swagger endpoint can be found at

http://localhost:3033/api

Custom event handlers

It's possible to handle events emitted by @energyweb/exchange in the @energyweb/origin-backend-app project. This feature allows 3rd party developers to implement custom event handling logic, additional to existing core event handlers.

Currently supported event is BulkTradeExecutedEvent which is emitted whenever new trade in the matching engine occurs.

In order to register custom event handler for this event please follow these steps:

  1. Create custom event handler code
import { BulkTradeExecutedEvent } from '@energyweb/exchange';
import { Logger } from '@nestjs/common';
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';

@EventsHandler(BulkTradeExecutedEvent)
export class NewTradeExecutedEventHandler implements IEventHandler<BulkTradeExecutedEvent> {
    private readonly logger = new Logger(NewTradeExecutedEventHandler.name);

    async handle(event: BulkTradeExecutedEvent) {
        this.logger.debug(`Received trade executed events ${JSON.stringify(event)}`);
    }
}

Note: This follows the recipe created by Nest.js team which is documented here https://docs.nestjs.com/recipes/cqrs

  1. Register your event handler as provider in origin-app.module.ts
@Module({})
export class OriginAppModule {
    static register(smartMeterReadingsAdapter: ISmartMeterReadingsAdapter): DynamicModule {
        return {
            module: OriginAppModule,
            imports: [
                OriginAppTypeOrmModule(),
                OriginBackendModule.register(smartMeterReadingsAdapter),
                ExchangeModule
            ],
            providers: [NewTradeExecutedEventHandler] // <-- add your event handler here
        };
    }
}

Note: Due to a way in which Nest.js is handling DI, your custom handler class name has to be unique, this means you should not use name taken by core event handler TradeExecutedEventHandler