Created
January 19, 2022 03:33
-
-
Save pscheit/505e194ddfeec157dd558bd07b9548ca to your computer and use it in GitHub Desktop.
Revisions
-
pscheit created this gist
Jan 19, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ node: image: node:17 command: ["node", "src/nodejs/express-server-converter-app.js"] working_dir: /app ports: - 83:80 volumes: - .:/app - /var/www/.cache 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ const express = require('express') const app = express() const port = 80 const markdownToRichtext = require('storyblok-markdown-richtext').markdownToRichtext app.use(express.text()) app.get('/', (req, res) => { res.send('hi there post to /convert with markdown as body and retrieve json back') }) app.post('/convert', (req, res) => { const richtextData = markdownToRichtext(req.body) res.setHeader('Content-Type', 'application/json'); res.send(JSON.stringify(richtextData)); }) const server = app.listen(port, "0.0.0.0", () => { console.log(`Converter app listening at http://0.0.0.0:${port}`) }) process.on('SIGTERM', () => { console.log('SIGTERM signal received: closing HTTP server') server.close(() => { console.log('HTTP server closed') }) })