This file contains 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
export default async (req: NextApiRequest, res: NextApiResponse) => { | |
const { | |
html, | |
css, | |
javascript = "", | |
viewportWidth = 640, | |
viewportHeight = 640, | |
imageFormat = "png", | |
} = req.body; |
This file contains 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 renderImage = async ( | |
html: string, | |
css: string, | |
javascript: string, | |
viewportWidth: number, | |
viewportHeight: number, | |
imageFormat: "jpeg" | "png" | |
): Promise<string> => { | |
const browser = await launchChromium(); |
This file contains 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
{ | |
"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": { |
This file contains 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
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 |
This file contains 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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
contract LockSave { | |
struct Saving { | |
address owner; | |
uint value; | |
uint timestamp; |
This file contains 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 { 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"); |
This file contains 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
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}); | |
} | |
_; |
This file contains 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
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; |
This file contains 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
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, | |
}; |
This file contains 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
describe("LockSave", function () { | |
let lockSave: Contract; | |
beforeEach(async () => { | |
// Deploy the contract | |
const LockSave = await ethers.getContractFactory("LockSave"); | |
lockSave = await LockSave.deploy(); | |
await lockSave.deployed(); | |
}); |
NewerOlder