/nr-fom-api

FOM - Forests Operational Mapping Project API

Primary LanguageJavaScriptApache License 2.0Apache-2.0

License

Forest Operation Map (FOM)

FOM projects (proposals for logging, essentially) are submitted to FOM and made available for public review and comment. The submitting organization then needs to address the comments before submitting the project to the ministry.

Technical Details

Technology Stack: Angular, Node.js, PostgresSQL with PostGIS running in OCP v4

This repo is for the Node.js API backend.

Third-Party Products/Libraries used and the licenses they are covered by

Project Status

  • Development
  • Production/Maintenance

Documentation

See ministry Confluence site: https://apps.nrs.gov.bc.ca/int/confluence/pages/viewpage.action?pageId=83560736

Security

Files in this repository

Getting Started

Local Development

Run API Backend (directly from code base)

Run API Backend as open-shift style container

  • docker build -f docker/api/Dockerfile.local -t api .
  • docker run -d --name api -p 3333:3333 -u 1001 --read-only -e DB_PASSWORD=test -e DB_NAME=api-db -e DB_USERNAME=postgres -e DB_HOST=localhost -e DB_TYPE=postgres -e DB_PORT=5432 api
  • WARNING: Currently doesn't work - fails with Error: connect ECONNREFUSED 127.0.0.1:5432

Connect to local database:

  • Install dbeaver or pgadmin
  • Ensure database is running (docker-compose up -d db && npm run typeorm:migrate)
  • Create PostGRES connection to local database using connection information as defined in docker-compose.yml

To rebuild local database from scratch

  • docker-compose down
  • docker volume rm nr-fom-api_ms-postgres-data
  • docker-compose up -d db
  • npm run db:migrate-main
  • npm run db:migrate-test
  • (Although migrations are also run when starting the API component)

Application Specific Setup:

This project uses the Nest API framework and the Nx monorepo platform / cli tools. Nx is used to manage this repository and generate Nest components. See FRAMEWORK.md for nrwl nx documentation.

Notes:

  • We use a custom OpenApi template when generating the frontend api clients from our Api
  • The .fetch-template bash script that does the clone and patch is in the apps/api/openapi dir
  • To generate the API client execute npm run gen:client-api
  • The generated client api library is located in libs/client

Deployment (OpenShift)

See OpenShift Readme

Getting Help or Reporting an Issue

To report bugs/issues/feature requests, please file an issue.

How to Contribute

If you would like to contribute, please see our CONTRIBUTING guidelines.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

Copyright 2021 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.