34 lines
757 B
JavaScript
34 lines
757 B
JavaScript
const express = require("express")
|
|
const bodyParser = require("body-parser")
|
|
const Airtable = require("airtable")
|
|
|
|
// Let's load some configuration!
|
|
require("dotenv").config()
|
|
|
|
const port = process.env.SNIPBOT_PORT || 5000
|
|
|
|
// Now it's time for setup!
|
|
Airtable.configure({
|
|
endpointUrl: process.env.SNIPBOT_AIRTABLE_ENDPOINT,
|
|
apiKey: process.env.SNIPBOT_AIRTABLE_API_KEY,
|
|
})
|
|
|
|
const base = Airtable.base(process.env.SNIPBOT_AIRTABLE_BASE_ID)
|
|
|
|
const app = express()
|
|
|
|
app.use(bodyParser.json())
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Server is running on port ${port}.`)
|
|
})
|
|
|
|
app.get("/", (req, res) => {
|
|
res.send({ status: "ok", message: "woof, woof!" })
|
|
})
|
|
|
|
app.post("/add", (req, res) => {
|
|
const { a, b } = req.body
|
|
res.send({ result: a + b })
|
|
})
|