neeramoy-sdk
v0.10.1
Published
A TypeScript SDK providing all backend functionality, including authentication, for the Neeramoy desktop application.
Downloads
234
Maintainers
Readme
TypeScript SDK for Neeramoy
A TypeScript/Node.js SDK for interacting with the Neeramoy Platform API.
This SDK provides resource classes and helper utilities for accessing clinics, doctors, appointments, dashboards, authentication, and user management.
Table of Contents
Features
- TypeScript first: Full typings, interfaces, and inline docs.
- Modular resources: Access clinics, doctors, appointments, dashboards, users, and authentication as separate modules.
- Built-in authentication: AWS Cognito-based OTP login, plus helpers for session handling.
- Central configuration: Set API URLs and authentication in one place.
- Flexible: Override headers, endpoints, and options as needed per request.
- Real-world examples: See the
examples/directory for ready-to-run usage.
Installation
npm install neeramoy-sdk
# or
yarn add neeramoy-sdkUsage
Library Setup
import { Library, LibraryConfig } from 'neeramoy-sdk';
const sdkConfig: LibraryConfig = {
baseUrl: 'https://your-api-base-url',
chatUrl: 'https://your-chat-url',
cloudFunctionUrl: 'https://your-cloud-function-url',
auth: {
userPoolId: 'your-cognito-user-pool-id',
userPoolClientId: 'your-cognito-client-id',
identityPoolId: 'your-cognito-identity-pool-id',
region: 'your-aws-region'
}
};
const sdk = new Library(sdkConfig);Authentication
Authenticate a user using OTP (one-time password) via AWS Cognito:
import promptSync from 'prompt-sync';
const prompt = promptSync();
const username = prompt('Enter your phone number (with country code): ');
const signInResult = await sdk.auth.signInWithOtp({ username });
console.log("OTP Sign-In Response:", signInResult);
if (signInResult.nextStep) {
const confirmationCode = prompt('Enter the OTP you received: ');
const confirmResult = await sdk.auth.confirmOtp({ username, confirmationCode });
console.log("Confirm OTP Response:", confirmResult);
}
const user = await sdk.auth.getCurrentUser();
console.log('Authenticated user:', user);Resource Usage Examples
Clinic
import { ClinicResource } from './src/resources/clinic/ClinicResource';
const clinicResource = new ClinicResource(sdk);
const clinicId = 'your-clinic-id';
const clinic = await clinicResource.getClinicById(clinicId);
console.log('Clinic profile:', clinic);Doctor
import { DoctorResource } from './src/resources/doctor/DoctorResource';
const doctorResource = new DoctorResource(sdk);
// Get doctor profile by ID
const profile = await doctorResource.getDoctorProfile('doctor-id');
// Search doctors
const params = { /* see DoctorSearchParams interface */ };
const searchResults = await doctorResource.searchDoctors(params);
// Get doctor settings at a specific clinic
const settings = await doctorResource.getDoctorClinicSettings('doctor-id', 'clinic-id');Appointments
import { AppointmentResource } from './src/resources/appointment/AppointmentResource';
const appointmentResource = new AppointmentResource(sdk);
// Example: Get available appointments
const available = await appointmentResource.getAvailableAppointments('doctor-id', 'clinic-id');Dashboard
import { DashboardResource } from './src/resources/dashboard/DashboardResource';
const dashboardResource = new DashboardResource(sdk);
const dashboard = await dashboardResource.getDashboardByClinicId('clinic-id', 'doctor-id', 'access-token');
console.log('Dashboard data:', dashboard);User
Public search by username
import { UserResource } from './src/resources/user/UserResource';
const userResource = new UserResource(sdk);
const user = await userResource.getUserDetails('+8801xxxxxxxxxx'); // Replace with actual phone number
console.log(user);Get current user details (requires access token)
const accessToken = 'your-access-token';
const currentUser = await userResource.getCurrentUserDetails({
headers: { Authorization: `Bearer ${accessToken}` }
});
console.log(currentUser);Project Structure
.
├── examples/ # Example usage scripts
│ ├── getUserByUsername.ts
│ ├── getCurrentUserDetails.ts
│ ├── getClinicDetail.ts
│ ├── getDoctorProfile.ts
│ ├── searchDoctors.ts
│ ├── testOtpLogin.ts
│ └── ...
│
├── src/
│ ├── index.ts # Library class, SDK entry
│ ├── resources/
│ │ ├── appointment/
│ │ ├── auth/
│ │ ├── clinic/
│ │ ├── dashboard/
│ │ ├── doctor/
│ │ ├── user/
│ │ └── base.ts
│ └── types/ # Shared types/interfaces (optional)
│
├── package.json
├── tsconfig.json
├── README.md
├── .env # For secrets in local development
└── ...Testing
- Run example scripts in the
examples/directory with Node.js. - Make sure to set up your
.envfile for any secrets or credentials required by the examples. - For unit/integration tests, consider using Jest or Mocha.
- Follow best practices for security: never commit sensitive keys or credentials.
Contributing
- Fork this repository.
- Create your feature branch (
git checkout -b feature/my-feature). - Commit your changes (
git commit -am 'Add some feature'). - Push to the branch (
git push origin feature/my-feature). - Open a pull request.
Code Style:
- Follow TypeScript best practices.
- Use consistent naming and folder structure.
- Write clear JSDoc comments.
Support
For questions, suggestions, or bugs, please open an issue.
