This project uses node.js and express to create a RESTful API for the gymsense project. Uses PostgreSQL as the database through the prisma ORM.
- Install node.js
- Install PostgreSQL
- Install prisma
- Clone this repository
- Run
npm install
in the root directory - Run
npm run dev
to start the server - Run
npm run prisma:generate
to generate the prisma client - Run
npm run prisma:migrate
to migrate the database - Run
npm run prisma:seed
to seed the database - Run
npm run prisma:studio
to open the prisma studio - Run
npm run prisma:reset
to reset the database - Run
npm run prisma:delete
to delete the database - Run
npm run prisma:generate
to generate the prisma client
Method | Endpoint | Description | Body |
---|---|---|---|
POST | /hub/create | Creates a new hub and generates a key | None |
POST | /iot/create | Creates a new iot device and generates a key | None |
POST | /iot/status | Updates the status of an iot device | json {hub_id: string, hub_key: string, id: string, key: string, battery_level: number, occupancy: boolean} |