CarbonFight is an OpenSource project. This repository contains backend serverless functions.
"CalculationsCO2e" is an API that allows you to determine the CO2e emissions of a daily action based on the 250 most common CO2e emission factors.
Swagger : API Swagger
Codacy : Codacy
Install Nodejs
# On Ubuntu
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
npm installInstall Firebase CLI
# On Ubuntu
sudo npm install -g firebase-tools
firebase loginInstall project dependencies :
# Working directory
cd functionsnpm installnpm install expressnpm install corsnpm install --save-dev jestnpm install jest supertest expressnpm install swagger-ui-expressConfigure emulator :
cd functions
firebase emulators:startExecute project :
firebase servehttp://localhost:5000/documentation/#/
Uncomment code in functions/index.js from line 24 to 28 to configure the server
const port = 3000;
app.listen(port, () => {
console.log(`Le serveur écoute sur le port ${port}...`);
});Run :
npm run localAccess the local Swagger documentation : http://localhost:3000/documentation/#/
npm test To update data, follow these steps:
Copy the serviceAccountKey.json file into import folder. Run the following command:
cd import
npm install
npm run dataConnect to your firebase account and run command :
firebase deploy --only functions --project <nomduprojet>Create firebase account : (https://firebase.google.com/) and connect.
Open terminal :
firebase loginInit the project :
firebase initDeploy project :
firebase deploy --only functions --project <nomduprojet>