Skip to content

Instantly share code, notes, and snippets.

View gracelungu's full-sized avatar

Grace Lungu gracelungu

View GitHub Profile
export default async (req: NextApiRequest, res: NextApiResponse) => {
const {
html,
css,
javascript = "",
viewportWidth = 640,
viewportHeight = 640,
imageFormat = "png",
} = req.body;
const renderImage = async (
html: string,
css: string,
javascript: string,
viewportWidth: number,
viewportHeight: number,
imageFormat: "jpeg" | "png"
): Promise<string> => {
const browser = await launchChromium();
{
"schema_version": "v1",
"name_for_human": "Web Render",
"name_for_model": "html_css_js_renderer",
"description_for_human": "Plugin for rendering HTML, CSS, and JavaScript into images, displaying the appearance of elements",
"description_for_model": "Plugin for rendering HTML, CSS, and JavaScript into images, displaying the appearance of elements",
"auth": {
"type": "none"
},
"api": {
openapi: 3.0.0
info:
title: HTML/CSS/JS to Markdown Image Link API
version: 1.0.0
servers:
- url: https://web-render.vercel.app/api
paths:
/render:
post:
summary: Render HTML, CSS, and JavaScript to a markdown image link
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract LockSave {
struct Saving {
address owner;
uint value;
uint timestamp;
import { expect } from "chai";
import { Contract } from "ethers";
import { ethers } from "hardhat";
describe("LockSave", function () {
let lockSave: Contract;
beforeEach(async () => {
// Deploy the contract
const LockSave = await ethers.getContractFactory("LockSave");
contract LockSave {
modifier isValidSaving (uint withdrawTimestamp) {
if(msg.value < 1){
revert UnauthorizedAmount({amount: msg.value, sender: msg.sender});
}
if(withdrawTimestamp > block.timestamp){
revert UnauthorizedWithdrawTime({withdrawTimestamp: withdrawTimestamp, sender: msg.sender});
}
_;
it("Should withdraw the savings", async function () {
// Amount to save
const ethAmount = "0.001";
const weiAmount = ethers.utils.parseEther(ethAmount);
const transaction = {
value: weiAmount,
};
// Withdraw timestamp
const withdrawTime = Date.now() + 1;
it("Should save and retrieve the savings data", async function () {
// Get the signer
const [sender] = await ethers.getSigners();
// Amount to save
const ethAmount = "0.001";
const weiAmount = ethers.utils.parseEther(ethAmount);
const transaction = {
value: weiAmount,
};
describe("LockSave", function () {
let lockSave: Contract;
beforeEach(async () => {
// Deploy the contract
const LockSave = await ethers.getContractFactory("LockSave");
lockSave = await LockSave.deploy();
await lockSave.deployed();
});