Skip to content

Commit 6d2bd21

Browse files
committed
Add basic copilot-instructions.md
1 parent 7d4e6d9 commit 6d2bd21

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/copilot-instructions.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copilot Instructions for AI Agents
2+
3+
## Project Overview
4+
This repository implements a Node.js module for sending push notifications across multiple platforms: Apple (APN), Google (GCM/FCM), Windows (WNS), Amazon (ADM), and Web-Push. The core logic is in `lib/` and `src/`, with each platform handled by a dedicated file (e.g., `sendAPN.js`, `sendFCM.js`).
5+
6+
## Architecture & Data Flow
7+
- **Entry Point:** Use `PushNotifications` from `lib/index.js` or `src/index.js`.
8+
- **Settings:** Each platform's credentials/config are passed to the constructor. See the example in `README.md`.
9+
- **Sending:** The main method is `push.send(registrationIds, data, callback)` or as a Promise. It auto-detects device type and routes to the correct sender.
10+
- **Platform Senders:** Each sender (e.g., `sendAPN.js`, `sendFCM.js`) implements the logic for its platform. Shared utilities are in `lib/utils/` and `src/utils/`.
11+
- **RegId Detection:** Device type is inferred from the registration ID structure. See `PN.getPushMethodByRegId` for details.
12+
13+
## Developer Workflows
14+
- **Install:** `npm install`
15+
- **Test:** Run all tests with `npm test`. Tests are in `test/` and cover basic flows and platform-specific cases.
16+
- **Debug:** Use the callback or Promise error/result from `push.send`. Each result object includes method, success/failure counts, and error details per device.
17+
- **Build:** No build step required for basic usage. ES6 is used, but compatible with ES5 via Babel if needed.
18+
19+
## Conventions & Patterns
20+
- **Platform-specific files:** Each push service has its own file for isolation and clarity.
21+
- **Unified Data Model:** The `data` object for notifications is normalized across platforms. See `README.md` for all supported fields.
22+
- **Error Handling:** Errors are unified and returned in the result array from `push.send`.
23+
- **RegId Format:** Prefer object format for registration IDs (`{id, type}`), but string format is supported for legacy reasons.
24+
- **Chunking:** Android tokens are chunked in batches of 1,000 automatically.
25+
- **Constants:** Use constants from `constants.js` for platform types.
26+
27+
## Integration Points
28+
- **External Libraries:**
29+
- APN: `node-apn`
30+
- FCM: `firebase-admin`
31+
- GCM: `node-gcm`
32+
- ADM: `node-adm`
33+
- WNS: `wns`
34+
- Web-Push: `web-push`
35+
- **Credentials:** Place service account keys and certificates in appropriate locations (see `README.md` for examples).
36+
37+
## Key Files & Directories
38+
- `lib/` and `src/`: Main implementation (mirrored structure)
39+
- `test/`: Test cases and sample credentials
40+
- `README.md`: Usage, configuration, and data model reference
41+
42+
## Example Usage
43+
See `README.md` for a full example of settings, registration ID formats, and sending notifications.
44+
45+
---
46+
For unclear or incomplete sections, please provide feedback or specify which workflows, patterns, or integrations need further documentation.

0 commit comments

Comments
 (0)