Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bloom-housing/backend-core

Package Overview
Dependencies
Maintainers
8
Versions
237
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloom-housing/backend-core

Listings service reference implementation for the Bloom affordable housing system

  • 6.0.1-alpha.1
  • npm
  • Socket score

Version published
Maintainers
8
Created
Source

Bloom Backend Services

This package is a NestJS application that provides a core set of backend services via REST API endpoints to apps using the Bloom Housing framework. Information is stored in a Postgres database, accessed via TypeORM.

OpenAPI Documentation

OpenAPI (fka Swagger) documentation is automatically generated by the server at http://localhost:3100/docs/ for a standard local development environment. A raw JSON version of the schema is also available at /docs-json/, suitable for API client code generation or other code-based consumers.

Getting Started

  • Install Node.js 14.x brew install node@14.
  • Install Postgres 12 brew install postgresql
  • Install Redis brew install redis
  • Copy the .env.template within backend/core to .env and edit variables appropriate to your local environment. Ensure sure the Database URL and Test Database URL match your Postgres configuration.
  • Install dependencies yarn install within backend/core

Redis

To start Redis: redis-server.

To launch Redis as background service and restart at login: brew services start redis.

Test if Redis is working: redis-cli ping

Seeding the Database

There are two databases used in this project: bloom and bloom_test. The first is used every time you are starting a project with yarn dev and second one is only used in end-to-end tests. Corresponding TypeORM configs are defined in ormconfig.ts and ormconfig.test.ts. If you are just starting to work with the projects it's best to simply run:

yarn && yarn db:reseed

which will create the bloom DB for you, migrate it to the latest schema, and seed with appropriate dev data. If running the reseed command requires that you input a password for Postgres, set the following environment variables: PGUSER to postgres and PGPASSWORD to the default password you inputted for the postgres user during Postgres installation. If you get the FATAL: database "<user>" does not exist error please run: createdb <user> first.

Dropping the DB:

yarn db:drop

Creating the DB:

yarn db:create

Seeding the DB:

yarn db:seed

Generating a new migration:

yarn db:migration:generate

Applying migrations:

yarn db:migration:run

Running Tests

End-to-end tests:

yarn test:e2e:local

Unit tests:

yarn test

Translations

The backend keeps translations for email related content in the DB in the translations table. The /translations endpoint exposes CRUD operations on this table (admin only). Translations are defined for each county code and language pair e.g. (Alameda, en). To modify a particular translation pair:

  1. Fetch GET /translations and list all the translations
  2. Find an ID of a pair that interest you
  3. Use PUT /translations/:translationId to modify it's content

Environment Variables

NameDescriptionDefaultType
PORTPort number the server will listen to for incoming connections3100number
NODE_ENVControls build optimization and enables some additional logging when set to developmentdevelopment"development" | "production"
DATABASE_URLDatabase connectionpostgres://localhost/bloomstring
TEST_DATABASE_URLTest database connectionpostgres://localhost/bloom_teststring
REDIS_TLS_URLSecure Redis connectionrediss://127.0.0.1:6379/string
REDIS_URLTCP Redis connection stringredis://127.0.0.1:6379/0string
REDIS_USE_TLSFlag controlling the use of TLS or unsecure transport for Redis00 | 1
THROTTLE_TTLRate limit TTL in seconds (currently used only for application submission endpoint)60number
THROTTLE_LIMITMax number of operations in given time window THROTTLE_TTL after which HTTP 429 Too Many Requests will be returned by the server2number
EMAIL_API_KEYSendgrid API key (see sendgrid docs for creating API keysAvailable internallystring
APP_SECRETSecret used for signing JWT tokens (generate it with e.g. openssl rand -hex 48)Available internallystring
PARTNERS_PORTAL_URLURL for partners sitehttp://localhost:3001string

FAQs

Package last updated on 28 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc