This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import slackifyMarkdown from "slackify-markdown"; | |
const headerForSlackMessage = () => { | |
return [ | |
{ | |
type: "header", | |
text: { | |
type: "plain_text", | |
text: "Bookmarks", | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// importing the required exposed methods from bookworms | |
import { loadBookmarks, generateBookmarks } from "bookworms"; | |
// don't really like this global but its fine for this hack | |
let bookmarks = ""; | |
// load the config into memory | |
const init = async () => { | |
// for production add some error handling | |
const { body } = await loadBookmarks.fetchBookmarkConfig("./bookmarks.yaml"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Fastify from "fastify"; | |
import fastifyForm from "fastify-formbody"; | |
import { init } from "./bookworms.js"; | |
import { sendBookMarks, sendBookmarkCommands} from "./slack.js"; | |
const fastify = Fastify(); | |
// fastifyForm is needed to get the body from a POST request | |
fastify.register(fastifyForm); | |
// creating a hook for Slack slash commands |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cluster = require('cluster'); | |
const numCPUs = require('os').cpus().length; | |
const fastify = require('fastify')(); | |
const port = 8123; | |
if (cluster.isMaster) { | |
console.log(`Master ${process.pid} is running`); | |
for (let i = 0; i < numCPUs; i++) { | |
cluster.fork(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fastify = require('fastify')(); | |
const port = 8123; | |
fastify.get('*', (req, res) => { | |
res.send('Hello World'); | |
}); | |
fastify.listen(port, () => { | |
console.log(`Fastify "Hello World" listening on port ${port}`); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const port = 8123; | |
const server = http.createServer((req, res) => { | |
res.write('Hello World'); | |
res.end(); | |
}); | |
server.listen(port, () => { | |
console.log(`HTTP "Hello World" listening on port ${port}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
func main() { | |
http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { |