The WhaleSpotting API is a controller-based ASP.NET api.
First, navigate to the ./api directory in the project repo.
To install dependencies, run:
$ dotnet restore
Please refer to "Setting up spatial data in the database" below before setting database
First, create a new role in pgAdmin called whale_spotting with password whale_spotting and the following priveleges:
- Can login
- Create databases
- Inherit rights from the parent roles
Prior to setting up database, install spatial data extension "PostGIS" for PostGres via stack builder application
Open pgAdmin --> Under databases , you can find the whale_spotting database. Right click on it and choose Query Tool. In the tab that appears, run the below queries to enable spatial data :
Create Extension postgis; Create Extension postgis_topology;
Then run:
$ dotnet ef database update
You can check that this has worked by right clicking on 'Databases' in pgAdmin and then clicking 'refresh'.
Currently, one default admin user is set up with username = whale_spotting and password “Whale_spotting1”.
We are using the following weather API: https://www.weatherapi.com/docs/ (We are using Marine Weather API Method) So please create an account to generate your own API Key. Once you have your API key you will need to run the following commands in your terminal to securely store your key.
Run this to initialise the user-secrets element which will store your API key:
$ dotnet user-secrets init
Then run to set your API key:
$ dotnet user-secrets set "WhaleSpotting:WeatherServiceApiKey" "<YOUR_API_KEY>"
You can run the code using dotnet run.
You can run the linter using dotnet format WhaleSpottingBackend.sln --verbosity diagnostic.
You can ensure it makes no changes using dotnet format WhaleSpottingBackend.sln --verify-no-changes --verbosity diagnostic.
CI pipeline will be automatically triggered on push and pull request. Please check the CI Pipeline Actions in GitHub to see if your commit passed. Diagnostic informaton will have more details on the where it failed.
This pipeline will fail if you don't follow the code style rules:
- tab width should be equal to 4 spaces
- all curly brackets (braces) should start and end on a new line
- delete any unnecessary trailing white spaces or empty lines at the end of your file
- mark your field declarations correctly, for instance
readonlyfor readonly properties. See Add readonly modifier - list your system directive imports first. For instance list
using System.IObeforeusing Microsoft.AspNetCore.Mvc. See dotnet formatting options