Skip to content

Commit

Permalink
doc: added basic readme, refs: #50
Browse files Browse the repository at this point in the history
  • Loading branch information
MCatherine1994 committed Nov 2, 2022
1 parent 65a17a9 commit 094b36d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 91 deletions.
80 changes: 5 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,15 @@
[![MIT License](https://img.shields.io/github/license/bcgov/nr-forest-client.svg)](/LICENSE.md)
[![Lifecycle](https://img.shields.io/badge/Lifecycle-Experimental-339999)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)

The vue-nest-template is a node.js application built with [Vue.js](https://vuejs.org) in typescript as frontend, [nestJS](https://docs.nestjs.com) as backend, postgres for database, integrated with the [greenfield-template](https://github.com/bcgov/greenfield-template) to automate the process for testing, security scanning, code quality checking, image building and deploying.
The nr-forest-client is a node.js application built with [Vue.js](https://vuejs.org) in typescript as frontend, [Spring boot java](https://spring.io/projects/spring-boot#learn) as backend, postgres and oracle for database, integrated with the [greenfield-template](https://github.com/bcgov/greenfield-template) to automate the process for testing, security scanning, code quality checking, image building and deploying.

# Setup
## Frontend

First need to create a new reposiroty in github
The frontend is built in Vue3 composition api

## Create a New Repo Using this Branch
## Backend

- `git clone https://github.com/bcgov/nr-old-growth.git [new_repo_name]` and switch to branch "vue-nest-template"
- `cd [new_repo_name]`, Remove the '.git' directory
- Re-initialize the git, `git init`
- Add the remote, `git remote add origin [new_repo_url]`

## Pipeline

- Update all the places using "**nrog**" in the yaml files under `.github/openshift` and `.github/workflows` folder, and update it to the new project name
- Add required secrets to github repo setting:
- General secrets:
- OC_SERVER: openshift cluster url
- GHCR_TOKEN: personal access token generated through user setting -> developer settings -> personal access token with the right to repo and write/delete package. We will need this personal token in the step of cleanup, deleting images. When use the default GITHUB_TOKEN auto generated by the pipeline. In this case the docker/build-push-action package need to have version > v3
- Environment secrets:
- Dev: OC_NAMESPACE (dev namespace), OC_TOKEN (get from openshift namespace -> administer view -> user management -> service account -> pipeline token)
- Prod: OC_NAMESPACE (prod namespace), OC_TOKEN
- Test: OC_NAMESPACE (test namespace), OC_TOKEN
- (Optional) If use the email service by CHES, add the CHES_SERVICE_CLIENT and CHES_CLIENT_PASSWORD to the github repo secrets as well

## Image Package

- Go the BCGov GitHub organization, search the new repo name, link the package registry to the repo, manage the access to open to public

## Frontend Local Development

- Create a .env file inside this frontend folder with the following options:

```
VITE_BACKEND_URL=http://localhost:3000
```
- (Optional) If want to enable the login authentication, add the following to the .env file as well, and uncomment the login setting in the `frontend/src/main.ts` file
```
VITE_KEYCLOAK_URL=[keycloak authentication url for dev server]
VITE_KEYCLOAK_CLIENT_ID=[keycloak client name]
VITE_KEYCLOAK_REALM=[keycloak realm name]
```
- Install all requirement packages: `npm install`
- Start the application: `npm start`

## Backend Local Development

- Create a .env file inside this backend folder with the following options (suppose there is a local postgres db to connect with):
```
NODE_ENV=development
POSTGRESQL_USER=[local postgres username]
POSTGRESQL_PASSWORD=[local postgres password]
POSTGRESQL_DATABASE=[local postgres database]
FRONTEND_URL=[enable cors for this frontend url]
BACKEND_URL=[enable cors for this backend url to enable try in swagger]
```
- (Optional) If want to use the email service by CHES, add the following to the .env file as well, and uncomment import in the `backend/src/app.module.ts` file
```
EMAIL_USERNAME=[CHES service dev username]
EMAIL_PASSWORD=[CHES service dev password]
// CHES dev authentication url
EMAIL_TOKEN_URL=https://dev.oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token
// CHES dev email url
EMAIL_POST_URL=https://ches-dev.apps.silver.devops.gov.bc.ca/api/v1/email
EMAIL_FROM=[send from email address]
```
- Install dependencies `npm install`
- Start the server `npm start`

## Database

- There is a sample sql script file at `backend/src/databasescripts/fsa.sql`, to run the script, open pgadmin, login to the db, right click on “Tables” -> “Query Tool” -> copy the query over and run it; right click on the schemas, and refresh to get the update


## Namespace

- For new namespace, add the network policy `oc process -f .github/openshift/networkPolicies.yml | oc apply -f -`
- If require more resources, apply at the [platform registry](https://registry.developer.gov.bc.ca/)
The backend is built in spring boot java with swagger

## Set up visual studio code

Expand Down
28 changes: 19 additions & 9 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<!-- PROJECT SHIELDS -->
The nr-forest-client backend provides the internal apis that support the frontend development.

[![Contributors](https://img.shields.io/github/contributors/bcgov/nr-forest-client)](/../../graphs/contributors)
[![Forks](https://img.shields.io/github/forks/bcgov/nr-forest-client)](/../../network/members)
[![Stargazers](https://img.shields.io/github/stars/bcgov/nr-forest-client)](/../../stargazers)
[![Issues](https://img.shields.io/github/issues/bcgov/nr-forest-client)](/../../issues)
[![MIT License](https://img.shields.io/github/license/bcgov/nr-forest-client.svg)](/LICENSE.md)
[![Lifecycle](https://img.shields.io/badge/Lifecycle-Experimental-339999)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)
## Setup local development

The nr-forest-client application provides the API that allows systems to consume forest client data without having to connect to a database. We are working the process to publish our API
```
- Export env variables for database credentials:
The nr-forest-client is a node.js application built with [nestJS](https://docs.nestjs.com), integrated with the [greenfield-template](https://github.com/bcgov/greenfield-template) to automate the process for testing, security scanning, code quality checking, image building and deploying. It is hosted in openshift, protected and published through [API Services Portal](https://api.gov.bc.ca/)
```

export ORACLEDB_HOST=[]
export ORACLEDB_PORT=[]
export ORACLEDB_SERVICENAME=[]
export ORACLEDB_USER=[]
export ORACLEDB_PASSWORD=[]

export POSTGRESQL_HOST=[]
export POSTGRESQL_DATABASE=[]
export POSTGRESQL_USER=[]
export POSTGRESQL_PASSWORD=[]

```
- Start the application: `./mvnw spring-boot:run`
- Rebuild the application if need: `./mvnw clean package`
- Run test: `./mvnw test`
```
7 changes: 0 additions & 7 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ VITE_KEYCLOAK_REALM=[keycloak realm name]

## Technology options

**Map**:
[Leaflet Map](https://leafletjs.com)
[vue-leaflet](https://github.com/vue-leaflet/vue-leaflet)
**Map Drawing**:
[leaflet-geoman](https://github.com/geoman-io/leaflet-geoman)
**Map Search**:
[leaflet-geosearch](https://github.com/smeijer/leaflet-geosearch)
**Unit Test**:
[Vitest](https://vitest.dev/api/)

Expand Down

0 comments on commit 094b36d

Please sign in to comment.