Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashiishme/ecometer
https://github.com/ashiishme/ecometer
Last synced: about 11 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/ashiishme/ecometer
- Owner: ashiishme
- License: mit
- Created: 2023-04-17T16:36:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-19T09:32:47.000Z (over 1 year ago)
- Last Synced: 2024-05-01T18:45:07.302Z (7 months ago)
- Language: TypeScript
- Size: 76.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Ecometer
Collect energy data from user to calculate energy consumption
# Project Structure
The application includes the backend of the application in below structure:
```bash
├── src
├── docker-compose.yml
...
..
```Inside the `src` there is a `forms` directory used for defining the form structure by hardcoding the fields.
# Running The Application
Please make sure you have the env file ready, you can find the sample in `server/.env.dist`.
As everything is dockerized, run the below docker command and the application will be ready to use:
```bash
docker compose up
```The backend server: http://localhost:8080
# Unit Tests
```bash
yarn test
```# API Endpoints
There are in total 2 endpoints available and are exposed as follows:
| Method | Path | Description |
| ------ | -------------------------------- | ------------------------------------------------------------------- |
| `GET` | `/api/v1/forms/:formName` | Gets the form structure of the given form |
| `POST` | `/api/v1/forms/:formName/submit` | Creates user and energy reading data on database for the given form |`GET /api/v1/forms/:formName`
Fetches the form structure of `formName`.
```
curl --request GET \
--url "http://localhost:8080/api/v1/forms/{my-form-name}"
````POST /api/v1/forms/:formName/submit`
Creates the data of user and energy reading
```
curl --request POST \
--url "http://localhost:8080/api/v1/forms/{my-form-name}/submit" \
--data '{
"energyInfo": {
"buildingType": "residential",
"numberOfResidential": 1,
"serialNumber": "123A1B2C",
"type": "electricity",
"reading": 6531231,
"city": "Berlin",
"zip": "12345",
"termsAndConditions": true
},
"user": {
"firstName": "Ashish",
"lastName": "Yadav",
"phoneNumber": "21435657",
"email": "[email protected]"
}
}'
```Please check the `forms` directory for the example form that can be used for the API request.