Deno Webhook Server is a real-time server application built using Deno. It supports WebSocket connections for real-time updates it includes endpoints for triggering reloads and retrieving messages.
- WebSocket Support: Real-time communication with clients.
- Message Handling: send and receive messages with validation.
- Reload Trigger: Notifies all connected clients to reload.
- Authentication: Secure endpoints with API key validation For Send and Reload Messages.
- Environment Configuration: Uses
.env
file for Store API Key.
- Deno: Ensure you have Deno installed. You can install it following the official guide.
- clone the repository or Download
git clone https://github.com/sanwebinfo/deno-webhook-server.git
cd deno-webhook-server
- Create the
.env
File
AUTH_KEY=your_secret_api_key
- Install Dependencies
deno cache server.ts
- Start the server using the following command
deno run --allow-net --allow-env --allow-read --allow-write server.ts
or
deno task start
URL: /ws
Method: WebSocket Upgrade
Description: Establish a WebSocket connection to receive real-time updates and message
- URL:
/reload
- Method: GET
- Description: Triggers a reload notification to all connected WebSocket clients.
- Headers: Authorization: Bearer <AUTH_KEY>
- URL:
/send-message
- Method: POST
- Description: Sends a message to all connected WebSocket clients.
- Request Body:
{
"message": "Your message here"
}
- Headers: Authorization: Bearer <AUTH_KEY>
## Send Message
curl -X POST http://localhost:8000/send-message \
-H "Authorization: Bearer your_secret_api_key" \
-H "Content-Type: application/json" \
-d '{"message": "Hello, WebSocket!"}'
## Reload page
curl -X GET http://localhost:8000/reload \
-H "Authorization: Bearer your_secret_api_key"
# Retrieve all stored messages
curl -X GET http://localhost:8000/messages
- open
http://localhost:8000
on Browser and check the WebSocket Activities
- Deno Deploy: https://deno.com/deploy
MIT