A TypeScript/Express.js API for calculating fees based on time periods, with Swagger documentation.
- Calculate fees for daily or monthly periods
- RESTful API with comprehensive error handling
- Swagger/OpenAPI documentation
- TypeScript for type safety
- Ready for deployment on Render
GET /- Health check endpointGET /api/- API health checkPOST /api/feeCalc- Calculate fees based on parametersGET /api-docs- Swagger UI documentation
- Node.js >= 18.0.0
- npm (included with Node.js)
-
Clone the repository
-
Install dependencies:
npm install
-
Run in development mode:
npm run dev
-
Build for production:
npm run build
-
Start production server:
npm start
The server will run on http://localhost:3000 by default.
Calculate fees based on time period and amount.
days(integer, optional): Number of days (use whenisMonthly=false)months(integer, optional): Number of months (use whenisMonthly=true)isMonthly(boolean, required): Whether to calculate monthly feesfees(number, required): Fee percentagemoney(number, required): Base amount to calculate fees on
Daily calculation:
curl -X POST "http://localhost:3000/api/feeCalc?days=10&isMonthly=false&fees=2.5&money=1000"Monthly calculation:
curl -X POST "http://localhost:3000/api/feeCalc?months=3&isMonthly=true&fees=5&money=2000""250$ in 10 days"├── src/
│ ├── index.ts # Main application entry point
│ ├── api/
│ │ └── api.ts # API routes and documentation
│ └── functions/
│ └── feeCalculator.ts # Core calculation logic
├── dist/ # Compiled JavaScript (generated)
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── render.yaml # Render deployment configuration
└── README.md # This file
npm run dev- Start development server with hot reloadnpm run build- Compile TypeScript to JavaScriptnpm start- Start production servernpm run postinstall- Automatically runs build after install
express- Web frameworkswagger-jsdoc- Generate Swagger specs from JSDocswagger-ui-express- Serve Swagger UIprompt-sync- Console input utility
typescript- TypeScript compiler@types/*- Type definitionsts-node- TypeScript execution for developmentnodemon- Development server with auto-restart
MIT License