A Node.js backend service for managing virtual beacons, providing registration, status updates, and location information to scanning devices.
- Virtual beacon registration and updates
- Active beacon status tracking
- Location-based beacon information
- Real-time beacon polling
- Automated cleanup of inactive beacons
- PostgreSQL database with Drizzle ORM
- Node.js (v16 or higher)
- PostgreSQL (v13 or higher)
- pnpm package manager
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- ORM: Drizzle ORM
- Language: TypeScript
- Development: ts-node-dev
- Clone the repository:
git clone https://github.com/rootCircle/BeaconifyStore.git
cd BeaconifyStore
- Install dependencies:
pnpm install
- Create a
.env
file in the root directory:
DATABASE_URL=postgres://user:password@localhost:5432/beaconify
PORT=3000
- Run database migrations:
pnpm run push
pnpm run dev
pnpm run build
pnpm start
- Endpoint:
POST /api/pollVBeacons
- Content-Type:
application/json
- Request Body:
{
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"major": "1234",
"minor": "5678",
"latitude": 37.7749,
"longitude": -122.4194
}
- Invocation:
curl -X POST http://localhost:3000/api/pollVBeacons \
-H "Content-Type: application/json" \
-d '{
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"major": "1234",
"minor": "5678",
"latitude": 37.7749,
"longitude": -122.4194
}'
- Response:
{
"success": true,
"message": "Beacon registered successfully",
"data": null
}
- Endpoint:
GET /api/getAllVBeacons
- Response:
{
"success": true,
"message": "Beacons retrieved successfully",
"data": [
{
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"major": "1234",
"minor": "5678",
"latitude": 37.7749,
"longitude": -122.4194,
"isActive": true,
"timestamp": "2024-02-14T12:00:00Z"
}
]
}
- Invocation:
curl http://localhost:3000/api/getAllVBeacons
- Endpoint:
POST /api/deactivateVBeacon
- Content-Type:
application/json
- Request Body:
{
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"major": "1234",
"minor": "5678"
}
- Invocation:
curl -X POST http://localhost:3000/api/deactivateVBeacon \
-H "Content-Type: application/json" \
-d '{
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"major": "1234",
"minor": "5678",
}'
- Response:
{
"success": true,
"message": "Beacon deactivated successfully",
}
The API uses standard HTTP status codes:
- 200: Success
- 400: Bad Request (invalid input)
- 404: Not Found
- 500: Internal Server Error
All error responses follow the format:
{
"success": false,
"message": "Error description",
"data": null
}
This project is licensed under the MIT License - see the LICENSE file for details.