Rune Rank

Server Examples

These are just barebones examples of how to get started and getting the vote-signature header. This helps protect your server and only allow Rune Rank callbacks.

Javascript example

server.js
import express from 'express'
import dotenv from 'dotenv'
 
dotenv.config()
 
const app = express()
const port = 3001
 
app.use(express.json())
 
app.post('/api/vote', (req, res) => {
  const signature = req.headers['vote-signature']
 
  // check if signature is valid
  if (!signature || signature !== process.env.RUNERANK_SIG_KEY) {
    console.log('Unauthorized request - Invalid or missing signature')
    return res
      .status(401)
      .json({ error: 'Unauthorized - Invalid or missing signature' })
  }
 
  // do something with Rune Rank data.
  console.log('Received vote callback data:', {
    timestamp: new Date().toISOString(),
    data: req.body
  })
 
  // return message (not needed)
  res.status(200).json({
    message: 'Vote data received successfully!',
    timestamp: new Date().toISOString()
  })
})
 
app.listen(port, () => {
  console.log(`Server listening on port ${port}`)
})

PHP example

server.php
 
 

On this page