Laundbot is a laundry service management system API that provides endpoints for managing shops, customers, items, treatments, orders, and users. The API is built using Node.js, Express, TypeScript, and PostgreSQL. It offers functionalities like creating shops, managing orders, handling packages, and more.
- User Management: Register, login, and manage user accounts.
- Shop Management: Create and manage shops associated with users.
- Customer Management: Add and manage customers within shops.
- Item Management: Define and manage laundry items.
- Package Management: Create and manage service packages for items.
- Treatment Management: Define and manage treatments and associated costs for items.
- Order Management: Create, update, and manage laundry orders.
- Node.js: JavaScript runtime for building server-side applications.
- Express: Web framework for Node.js.
- TypeScript: Typed superset of JavaScript for better code quality and maintainability.
- PostgreSQL: Relational database management system.
- TypeORM: ORM for TypeScript and JavaScript.
- Swagger: API documentation.
- Docker: Containerization for development and deployment.
- Jest: Testing framework for JavaScript.
- Node.js (version 14.x or later)
- PostgreSQL (version 12 or later)
- Docker (optional, for containerized development)
- Git
-
Clone the Repository
git clone https://github.com/emeriego/laundbot-api.git cd laundbot-api
-
Install Dependencies
npm install
-
Set Up Environment Variables
Create a
.env
file in the root directory and add the following environment variables:PORT=3000 DATABASE_URL=postgres://username:password@localhost:5432/laundbot JWT_SECRET=your_jwt_secret
-
Run the Database Migrations
If you're using TypeORM, run the migrations to set up the database schema:
npm run typeorm migration:run
-
Start the Application
npm run dev
The API should now be running at
http://localhost:3000
.
-
Build the Docker Image
docker build -t laundbot-api .
-
Run the Container
docker run -p 3000:3000 --env-file .env laundbot-api
The API should now be running at
http://localhost:3000
.
The API is documented using Swagger. Once the server is running, you can access the API documentation at:
http://localhost:3000/api-docs
POST /auth/register
: Register a new user.POST /auth/login
: Login a user.
POST /api/shops/create
: Create a new shop.GET /api/shops
: Get all shops.
POST /api/customers/create
: Create a new customer.GET /api/customers
: Get all customers.
POST /api/items/create
: Create new items.GET /api/items
: Get all items.
POST /api/packages/create
: Create new packages.GET /api/packages
: Get all packages.
POST /api/treatments/create
: Create new treatments.GET /api/treatments
: Get all treatments.
POST /api/orders/create
: Create a new order.GET /api/orders
: Get all orders.GET /api/orders/:orderId
: Get an order by ID.PUT /api/orders/:orderId
: Update an order.PUT /api/orders/:orderId/status
: Update an order's status.
laundbot-api/
├── src/
│ ├── controllers/ # Request handlers for routes
│ ├── routes/ # API routes definitions
│ ├── services/ # Business logic
│ ├── models/ # Database models (TypeORM entities)
│ ├── middlewares/ # Custom middlewares
│ ├── utils/ # Utility functions
│ ├── data-source.ts # TypeORM data source configuration
│ ├── app.ts # Express app initialization
│ └── server.ts # Server entry point
├── .env # Environment variables
├── package.json # NPM dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
Run unit tests using Jest:
npm test
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, please reach out to Godwin Ojukwu.