Add handler
This commit is contained in:
parent
542616a74a
commit
a0a1e93f68
|
@ -1,2 +1,3 @@
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
dev.html
|
11
card.js
11
card.js
|
@ -3,7 +3,7 @@ const { getScreenshot } = require('./chromium');
|
||||||
const { getHtml } = require('./template');
|
const { getHtml } = require('./template');
|
||||||
const { writeTempFile, pathToFileURL } = require('./file');
|
const { writeTempFile, pathToFileURL } = require('./file');
|
||||||
|
|
||||||
module.exports = async function (req, res) {
|
async function handler(req, res) {
|
||||||
try {
|
try {
|
||||||
let {
|
let {
|
||||||
type = 'png',
|
type = 'png',
|
||||||
|
@ -28,3 +28,12 @@ module.exports = async function (req, res) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (!process.env.NOW_REGION) {
|
||||||
|
const { createServer } = require('http');
|
||||||
|
const PORT = process.env.PORT || 3000;
|
||||||
|
const listen = () => console.log(`Listening on ${PORT}...`);
|
||||||
|
createServer(handler).listen(PORT, listen);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = handler;
|
|
@ -4,7 +4,7 @@
|
||||||
"description": "Generate an open graph image for twitter/facebook/etc",
|
"description": "Generate an open graph image for twitter/facebook/etc",
|
||||||
"main": "card.js",
|
"main": "card.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node dev.js"
|
"start": "node card.js"
|
||||||
},
|
},
|
||||||
"author": "styfle",
|
"author": "styfle",
|
||||||
"repository": "github:styfle/og-image",
|
"repository": "github:styfle/og-image",
|
||||||
|
|
Loading…
Reference in New Issue