Skip to content

Instantly share code, notes, and snippets.

View ajaykarthikr's full-sized avatar
🚀
Shipping things!

Ajay Karthik ajaykarthikr

🚀
Shipping things!
View GitHub Profile
const serverless = require("serverless-http");
const express = require("express");
const app = express();
app.get("/", (req, res, next) => {
return res.status(200).json({
message: "Hello from root!",
});
});
app.get("/hello", (req, res, next) => {
return res.status(200).json({
service: pdf-generator
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs14.x
region: ap-south-1
stage: ${opt:stage, 'dev'}
timeout: 28
const chromium = require('chrome-aws-lambda');
const playwright = require('playwright-core');
const serverless = require("serverless-http");
const express = require("express");
const app = express();
app.get("/", async function (req, res) {
let browser = null;
var resp = {}
const chromium = require('chrome-aws-lambda');
const playwright = require('playwright-core');
const serverless = require("serverless-http");
const express = require("express");
const app = express();
app.get("/", async function (req, res) {
let browser = null;
var resp = {}
if(!req.query?.url)
throw Error("Url not present in query")
await page.goto(req.query.url);
functions:
hello:
handler: index.handler
events:
- httpApi:
path: /
method: POST
app.post("/", async function (req, res) {
return res.status(400).json({data: 'hello world'})
});
<html>
<head>
<style type="text/css">
#header {
padding: 0 !important;
}
.content {
width: 100%;
height: 12px;
background-color: #42a5f6;
const templateHeader = fs.readFileSync('header.html','utf-8');
const templateFooter = fs.readFileSync('footer.html','utf-8');
const data = await page.pdf({
displayHeaderFooter: true,
headerTemplate: templateHeader,
footerTemplate: templateFooter,
margin: {
top: '16px',
bottom: '36px',
},