From 6c8486457319fa41930ecb8402fc35e3cc30b231 Mon Sep 17 00:00:00 2001 From: Gaurang Jadia Date: Mon, 7 Nov 2022 18:04:40 -0800 Subject: [PATCH] Fixed the API Endpoint Path and added Docs for Image and PDF --- README.md | 32 ++++++++++++++++++++++++++------ app.js | 8 ++++---- views/partials/footer.ejs | 2 +- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 01675e4..fd1a29d 100644 --- a/README.md +++ b/README.md @@ -9,28 +9,46 @@ ScreenshotCrew is an open-source screenshot as a service using [Puppeteer headless browser](https://github.com/puppeteer/puppeteer). Using Node.js, [Puppeteer](https://pptr.dev/) and other plugins, ScreenshotCrew provides utility tool to create screenshot from any web page. ## Motivation -* https://screenshotlayer.com/ -* https://urlbox.io/ -* https://browshot.com/ -* https://screenshotmachine.com/ + +* [https://screenshotlayer.com/](https://screenshotlayer.com/) +* [https://urlbox.io/](https://urlbox.io/) +* [https://browshot.com/](https://browshot.com/) +* [https://screenshotmachine.com/](https://screenshotmachine.com/) ## Demo + [https://screenshotcrew.com/](https://screenshotcrew.com/) ## API Reference +### Image + ```bash -curl --location --request GET "https://screenshotcrew.com/api/capture?width=1920&url=https://gaurangjadia.com" +curl --location --request GET "https://screenshotcrew.com/api/capture/image?width=1920&url=https://gaurangjadia.com" ``` ```bash -curl --location --request POST "https://screenshotcrew.com/api/capture" --header "Content-Type: application/json" --data-raw "{ +curl --location --request POST "https://screenshotcrew.com/api/capture/image" --header "Content-Type: application/json" --data-raw "{ \"width\": 1920, \"url\": \"https://gaurangjadia.com\" }" ``` +### PDF + +```bash +curl --location --request GET "https://screenshotcrew.com/api/capture/pdf?pageSize=A4&url=https://gaurangjadia.com" +``` + +```bash +curl --location --request POST "https://screenshotcrew.com/api/capture/pdf" --header "Content-Type: application/json" --data-raw "{ + \"pageSize\": \"A4\", + \"url\": \"https://gaurangjadia.com\" +}" +``` + ## Installation + ```base npm install npm update @@ -58,9 +76,11 @@ docker run -d -p 80:80 jadiagaurang/screenshotcrew ``` ## Tests + ```base npm test ``` ## License + Please see the [license file](https://github.com/jadiagaurang/ScreenshotCrew/blob/main/LICENSE) for more information. diff --git a/app.js b/app.js index 0b899e3..b1ae0ac 100644 --- a/app.js +++ b/app.js @@ -15,8 +15,8 @@ const { createTerminus } = require("@godaddy/terminus") // Load local plugins const winston = require("./src/logger").winston; -const routes = require("./routes/index"); -const shotbot = require('./routes/shotbot'); +const routesViews = require("./routes/index"); +const routesAPIEndpoints = require('./routes/shotbot'); var meLogger = winston(process.env.LOG_LEVEL); // ExpressJS App Setup @@ -54,8 +54,8 @@ app.use(cookieParser()); app.use(express.static(path.join(__dirname, "public"))); // WebApp and API Route Setup -app.use("/", routes); -app.use("/api", shotbot); +app.use("/", routesViews); +app.use("/api", routesAPIEndpoints); // Catch 404 and forward to error handler app.use(function (req, res, next) { diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs index fbb2888..dec596f 100644 --- a/views/partials/footer.ejs +++ b/views/partials/footer.ejs @@ -38,7 +38,7 @@ } let xhr = $.ajax({ - url: "/api/capture", + url: "/api/capture/image", method: "POST", data: { "url": varURL