B. Server Setup
Please read the server's README file in /server/README.md as reference for more information on the server environment variables.
The 08 Server Setup for Localhost Development (opens in a new tab) video tutorial shows how to initialize the server for localhost development in more detail.
Setup environment variables
Create a .env
file inside the /server directory. Copy the contents of the .env.example
file in it.
- Replace the
FIREBASE_SERVICE_ACC
variable with the Firebase project's private key from it's service account JSON file. - Replace the
FIREBASE_PRIVATE_KEY
variable with theFIREBASE_SERVICE_ACC
's private_key entry. - Replace the
FIREBASE_STORAGE_BUCKET
variable with your Firebase project's storage bucket - Replace the
REGION_NAME
variable with a string (no white space) representing the name of your new target regionℹ️The server
REGION_NAME
should be similar with the clientREGION_NAME
value. - Set
AXIOS_SSL_REJECT_INVALID
to0
- If
AXIOS_SSL_REJECT_INVALID
does not yet exist, please make sure that your forked repository have the most recent update from the upstream repository. - The
AXIOS_SSL_REJECT_INVALID
variable was added recently in ACAP-Bicol 1.0v9.3.13
to fix a new bug that fails web scraping PAGASA's tropical cyclone and El Nino / La Nina web pages.
- If
- Initially set
CHECK_RANGE_YEAR
to0
.- This variable validates that the 10-day PAGASA Excel files downloads contain the latest year.
- Running the
npm run seed:all
script below will throw an error if this variable set to1
, since the sample local 10-day PAGASA Excel files used for seeding initial data have outdated dates - Set it back to
CHECK_RANGE_YEAR=1
after running theseed:all
script.
- Set
SPECIAL_CHARACTERS
to├â┬▒:ñ,â:
- This variable converts the
ñ
garbled text toñ
from municipality names containing the ñ character in the PAGASA 10-day weather forecast Excel files. - Add other key-value pairs of special characters and their normalized values, delimited by a comma as needed
- Read on this reference (opens in a new tab) for more information about this bug.
- This variable converts the
- ACAP 2.0 introduces several new environment variables. Add the following, while refering to the server's README file in /server/README.md for more information about these variables. Some variables need to be added or excluded in order to enable or disable the ACAP-RCMAS APIs.
SPECIAL_CHARACTERS
DEPLOYMENT_PLATFORM=default
PROVINCES_ARCHIVE
- Set its value after running 2. Initialize provinces and municipalitiesACAP_API_KEYS
IS_RMCAS_API_ACTIVE=0
ARCHIVE_TENDAY_FORECAST=0
ROOT_API_URL
ROOT_API_URL_VERCEL
CHECK_RANGE_YEAR
Initialize provinces and municipalities
ACAP refers to the PAGASA Seasonal Forecast - Forecast Rainfall Analysis Table (opens in a new tab) for its regional provinces list, matching the province names with those listed in the PAGASA 10-day Weather Forecast Excel (opens in a new tab) files.
ACAP expects province naming from the two (2) data sources to match since both are data products produced by PAGASA.
Run ACAP's "pagasa:municipalities"
NPM script to get a list of the PAGASA municipalities and province names.
-
First, navigate to the server directory from the command line, then run:
npm run pagasa:municipalities
INFO: The
"pagasa:municipalities"
NPM script uses a static-encoded region/province mapping file, manually encoded in 2024 with reference from the PAGASA Seasonal Forecast - Forecast Rainfall Analysis table. -
Enter PAGASA's 10-day Excel file URL when prompted.
- These files, updated daily around 8:00 AM, are available on https://www.pagasa.dost.gov.ph/climate/climate-prediction/10-day-climate-forecast (opens in a new tab)
- Enter a specific PAGASA's 10-day Excel file URL when prompted:
https://pubfiles.pagasa.dost.gov.ph/pagasaweb/files/climate/tendayweatheroutlook/day1.xlsx
-
Double-check the resulting province names from step #2 with those listed in the latest PAGASA Seasonal Forecast - Forecast Rainfall Analysis (opens in a new tab) table. Take note of new province(s) not included in the generated list, or remove provinces no longer present in the Forecast Rainfall Analysis table.
⚠️The
"pagasa:municipalities"
NPM script may generate an outdated or incorrect list of provinces of a region depending on several factors.-
Visit the Provinces and Municipalities FAQs or the Regional Provinces / Municipalities Inconsistency sections for more information on why this may happen.
-
Refer to the Updating Regional Provinces guide for possible troubleshooting methods if you notice missing provinces or municipalities after running this script.
-
-
Replace the
PROVINCES
andPROVINCES_ARCHIVE
variables with the comma-separated province names of your new target region resulting from steps #2 and #3. -
Replace the
DEFAULT_PROVINCE
.env variable with any province name from thePROVINCES
comma-separated province names.
Create new superadmin password
- Open the the file:
/server/src/scripts/seeders/00_superadmin/index.js
- Add a
password
parameter to theparams
object. Enter a random password, and remember its value.const params = { ..., displayname: 'Super Admin', account_level: 1, password: 'some_super_secret_password' }
Seed default data
This script initializes the Firestore database with default values. Navigate to the server folder from the command line and run the NPM script:
npm run seed:all
- This script will create default, mock (empty) values to designated Firestore collections and documents using the defined region and provinces in the .env file, which should be updated later with real values.
- This script expects to finish without errors. Re-trace, debug and troubleshoot errors, if any will show, before proceeding to the Client Set-up section.
Initialize 10-day weather forecast
Run this server NPM script to fetch and upload the @latest PAGASA 10-day weather forecast data to the Firestore database. Navigate to the server folder from the command line and run the NPM script:
npm run cron:tenday
This script may fail to fetch and parse 10-day weather forecast data of several municipalities linked with provinces not available in the 10-day Excel file.
Visit the Provinces and Municipalities article for more information if you notice missing 10-day weather forecast data for several provinces and municipalities.
Build the API docs (Optional)
(Optional) Build ACAP server's REST API documentation website for reference.
- Navigate to the server folder from the command line and run the NPM script:
npm run gen:docs
- Go to the /server/src/public/docs folder and click the index.html file to view the generated API documentation.
- The API documentation website is also available on
http://localhost:3001/docs
after running the server app.
- The API documentation website is also available on