A professional Node.js/Express server designed to keep APIs alive by periodically pinging internal and external endpoints. It features a /api/developer endpoint that returns sarcastic developer messages to mimic human-like activity, helping bypass AI verification. If external APIs are down, it sends push notifications via Expo.
- Internal API:
/api/developerreturns one of 20 sarcastic developer messages. - Cron Jobs: Periodically pings internal and external APIs (every 5 minutes by default).
- External API Monitoring: Checks the status of external APIs and logs their availability.
- Push Notifications: Sends Expo push notifications when external APIs are down.
- Environment Variables: Configurable via
.envfor secure and flexible deployment.
- Node.js (v16 or higher)
- npm or yarn
- Expo account for push notifications
- A publicly accessible domain for the server
-
Clone the repository:
git clone https://github.com/bishaldahal/server-keepalive.git cd server-keepalive -
Install dependencies:
npm install
-
Create a
.envfile based on.env.example:cp .env.example .env
Update
.envwith your configuration:PORT: Server port (e.g.,3000)HOSTED_DOMAIN: Public server URL (e.g.,https://your-domain.com)EXTERNAL_APIS: Comma-separated list of external API URLsPUSH_TOKENS: Comma-separated list of Expo push tokens
-
Run the server:
npm start
For development with auto-restart:
npm run dev
Edit .env to configure:
PORT: The port the server runs on.HOSTED_DOMAIN: The public URL of your server (must use HTTPS in production).EXTERNAL_APIS: List of external APIs to monitor (e.g.,https://api1.com,https://api2.com).PUSH_TOKENS: Expo push tokens for notifications (e.g.,ExponentPushToken[xxxx]).
Note: Do not commit .env to version control. Use .env.example as a template.
- GET /api/developer: Returns a random sarcastic message related to software development.
Deploy to a platform like Render, Heroku, or AWS:
- Set environment variables in the platform’s dashboard.
- Ensure
HOSTED_DOMAINmatches the deployed URL. - Verify HTTPS is enabled.
- Test the
/api/developerendpoint and cron jobs.
- Authentication: Consider adding API key authentication to
/api/developerfor public deployments. - Environment Variables: Store sensitive data in
.envand exclude it from version control. - HTTPS: Use HTTPS for
HOSTED_DOMAINto ensure secure communication.
- Local Testing: Use
curl https://your-domain.com/api/developeror ngrok for local development. - Push Notifications: Test with Expo’s push notification tool (https://expo.dev/notifications).
- Cron Jobs: Check server logs to verify internal and external API pings.
Contributions are welcome! Please open an issue or pull request on GitHub.
MIT License