A robust API for managing medical dictionary terms with user authentication and role-based access control.
https://specialist-dictionary-api.binarybinayak.com
The API uses JWT (JSON Web Token) authentication. Tokens are provided via cookies upon successful login/signup.
- POST
/auth/signup - Body:
{ "name": "string", "email": "string", "password": "string" } - Response: Returns user details and sets authentication cookie
- POST
/auth/login - Body:
{ "email": "string", "password": "string" } - Response: Returns user details and sets authentication cookie
All these routes require authentication
- GET
/user - Response: Returns current user details
- PATCH
/user - Body:
{ "name": "string", "userType": "string" // optional } - Response: Returns updated user details
- PATCH
/user/password - Body:
{ "currentPassword": "string", "newPassword": "string" } - Response: Returns success message
- GET
/medical-dictionary?word=example - Query Parameters:
word(required) - Response: Returns word definition and details
- GET
/medical-dictionary/search?query=example - Query Parameters:
query(required) - Response: Returns matching words
- POST
/medical-dictionary/request-update - Body:
{ "word": "string", "definition": "string", "explanation": "string" } - Response: Returns update request details
- POST
/medical-dictionary/request-delete - Body:
{ "word": "string", "reason": "string" } - Response: Returns delete request details
- POST
/medical-dictionary - Body:
{ "word": "string", "definition": "string", "explanation": "string" } - Response: Returns added/updated word details
- GET
/medical-dictionary/update-requests - Response: Returns list of pending update requests
- GET
/medical-dictionary/delete-requests - Response: Returns list of pending delete requests
All errors follow this format:
{
"message": "Error description"
}Common HTTP status codes:
- 400: Bad Request
- 401: Unauthorized
- 403: Forbidden
- 404: Not Found
- 500: Internal Server Error
- Regular User: Can view words and submit update/delete requests
- Editor: Can approve/reject requests and modify dictionary content
- Admin: Has full access to all features
Required environment variables:
- PORT: Server port (default 80 for production)
- MONGODB_CONNECTION_SECRET: MongoDB connection string
- JWT_SECRET: Secret for JWT token generation
- BCRYPT_SALT_ROUNDS: Number of salt rounds for password hashing
- ALLOWED_ORIGINS: Comma-separated list of allowed CORS origins
- Clone the repository
- Install dependencies:
npm install - Set up environment variables in
.env - Run development server:
npm run dev - Build for production:
npm run build
The API is containerized and deployed using CapRover. See Dockerfile for container configuration.
- Node.js
- Express.js
- TypeScript
- MongoDB with Mongoose
- JWT for authentication
- bcrypt for password hashing