SelfServe is a hotel self-service platform API that enables guests to manage their hotel stay, communicate with staff, request services, and provide feedback. This API serves as the backend for the SelfServe mobile and web applications.
- Guest Profile Management: View and update guest information and preferences
- Messaging System: Guest-staff communication and hotel announcements
- Feedback Collection: Guest ratings and reviews for hotel services
- Service Requests: Dining, housekeeping, maintenance, and amenity requests
- Reservation Management: View and manage reservations
- Node.js: JavaScript runtime
- Express: Web framework
- TypeScript: Type-safe JavaScript
- PostgreSQL: Database
- Drizzle ORM: Object-Relational Mapping
- Swagger/OpenAPI: API documentation
- Node.js (v16 or higher)
- PostgreSQL (v14 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/yourusername/selfserve-api.git cd selfserve-api -
Install dependencies
npm install -
Set up environment variables
cp .env.example .envEdit the
.envfile with your database credentials and other configurations. -
Run database migrations
npm run db:migrate -
Seed the database (optional)
npm run db:seed -
Start the development server
npm run dev
The API will be available at http://localhost:3000. The Swagger UI for API documentation is available at http://localhost:3000/api-docs.
The API documentation is available in several formats:
- Swagger UI: Available at
/api-docswhen running in development mode. - OpenAPI Spec: Available at
/api-docs.jsonwhen running in development mode. - Markdown: See
docs/API-REFERENCE.mdfor a comprehensive API reference.
βββ src/
β βββ api/ # API routes and controllers
β β βββ guest/ # Guest-facing endpoints
β β βββ management/ # Management endpoints
β βββ config/ # Configuration files
β βββ middleware/ # Express middleware
β βββ models/ # Database models
β βββ types/ # TypeScript type definitions
β βββ utils/ # Utility functions
β βββ index.ts # Application entry point
βββ docs/ # Documentation
βββ migrations/ # Database migrations
βββ seeds/ # Database seed data
βββ tests/ # Test files
βββ .env # Environment variables
npm run test
npm run lint
npm run build
The API uses a standardized error handling approach. All errors returned follow a consistent format:
{
"error": {
"message": "Error description",
"type": "ErrorType",
"details": []
}
}The API uses header-based authentication with the following headers:
X-Guest-ID: For guest authenticationX-Hotel-ID: For hotel-specific operations
This project is licensed under the MIT License - see the LICENSE file for details.