UNPKG

@waline/vercel

Version:

vercel server for waline comment system

44 lines (35 loc) 932 B
const Model = require('think-model'); const Mongo = require('think-mongo'); const { isNetlify, netlifyFunctionPrefix } = require('./netlify'); module.exports = [ Model(think.app), Mongo(think.app), { context: { get serverURL() { const { SERVER_URL } = process.env; if (SERVER_URL) { return SERVER_URL; } const { protocol, host } = this; if (isNetlify) { return `${protocol}://${host}${netlifyFunctionPrefix}`; } return `${protocol}://${host}`; }, async webhook(type, data) { const { WEBHOOK } = process.env; if (!WEBHOOK) { return; } return fetch(WEBHOOK, { method: 'POST', headers: { 'content-type': 'application/json', }, body: JSON.stringify({ type, data }), }).then((resp) => resp.json()); }, }, }, ];