CarbonRoutes provides routes for retrieving the carbon reduction estimate. It requires a json file at RESOURCE_CARBON_LOCATIONS in resources, it should be an array of CountryLocationStruct

const carbonRepo: CarbonRepository
const resources: ResourcesMap
const store: KeyValueService
const carbonOriginCountry = 'GB'

const app = express().use(express.json())

const carbonRoutes = new CarbonRoutes({
carbonRepo,
resources,
store,
carbonOriginCountry,
})

Hierarchy

  • CarbonRoutes

Constructors

Methods

Constructors

Methods

  • getCarbon gets the carbon reduction estimate and the total distance travelled. This can be computationally expensive so the value is cached in the store for 5 minutes.

    app.get('/carbon/estimate', async (req, res) => {
    res.send(
    await carbonRoutes.getCarbon()
    )
    })

    Returns Promise<CarbonCalculation>

Generated using TypeDoc