A Node.js GraphQL service migrated from the Golang merchantuiapisvc project. This service provides GraphQL APIs for EPOS operations.
This project is a minimal viable product (MVP) that migrates the EPOS functionality from a Golang-based REST API service to a modern Node.js GraphQL service using TypeScript and Apollo Server.
- Terminal Management: CRUD operations for merchant terminals
- Role Management: Manage merchant roles and permissions
- GraphQL API: Modern GraphQL API with type safety
- TypeScript: Full TypeScript support for better development experience
- Middleware: Authentication, logging, rate limiting, and security
- Error Handling: Comprehensive error handling and logging
src/
├── config/ # Application configuration
├── datasources/ # Data access layer (equivalent to repos in Golang)
├── graphql/ # GraphQL schemas, resolvers, and scalars
│ ├── resolvers/ # GraphQL resolvers
│ ├── schemas/ # GraphQL schema definitions
│ └── scalars.ts # Custom scalar types
├── middlewares/ # Express and GraphQL middlewares
├── models/ # TypeScript interfaces and types
├── server/ # Server setup and initialization
├── services/ # Business logic layer
└── utils/ # Utility functions (logger, HTTP client, etc.)
- Node.js with TypeScript
- Apollo Server for GraphQL
- Express.js for HTTP server
- Axios for HTTP client communication
- Winston for logging
- Jest for testing
- ESLint + Prettier for code quality
- Node.js (v16 or higher)
- npm or yarn
- Access to the EPOS microservice (backend)
- Clone the repository:
git clone <repository-url>
cd graphql-project- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Build the project:
npm run build- Start the development server:
npm run devThe GraphQL playground will be available at http://localhost:4000/graphql
Create a .env file with the following variables:
# Environment
NODE_ENV=development
# Server Configuration
PORT=4000
HOST=localhost
# Logging
LOG_LEVEL=info
# External Services (Epos Microservice)
EPOS_SERVICE_BASE_URL=http://localhost:8080
EPOS_SERVICE_TIMEOUT=30000
# Security
JWT_SECRET=your-jwt-secret-here
CORS_ORIGIN=http://localhost:3000
# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100getTerminals(input: TerminalListInput): Get list of terminals
- NA
curl --location --request POST 'http://localhost:4000/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJra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UCCESS",
"message": "Terminal list for merchant fetched successfully!",
"data": [
{
"terminalId": "1965",
"merchantId": "73000",
"agentName": "sdf"
},
{
"terminalId": "3752",
"merchantId": "73000",
"agentName": "asd"
},
{
"terminalId": "2035",
"merchantId": "73000",
"agentName": "fyfjhfvj"
}
]
}
}
}