Code Monkey home page Code Monkey logo

express-prerender's Introduction

s-prerender

This app is a solution for SPA problems with SEO.

Getting start

Running on local environment the API require instance of Redis. Before start development locally, please make sure you have installed Chrome browser and instance of Redis was run. (MAC | Windows)

install dependencies

npm install

Run prerender API

npm run start

Run for local development with watching file changes by nodemon

npm run start:dev

Development using Docker

Please, take in mind, that the Dockerfile isn't for local usage. It exists to simplify inserting the app into complex infrastructures. For development, please use docker-compose.yml only.

Run instance for local development with watching file changes by nodemon

docker compose up

Deploy

Deployment using Dockerfile require only REDIS_URL.

REDIS_URL= connection to Redis within your environment

RABBITMQ_URL= connection to RabbitMQ within your environment (optional)

Defaults

  • PORT=3636
  • DEBUG=false
  • HOST=0.0.0.0
  • ALLOW_DOMAINS=.
  • CHROME_DEBUGGING_PORT=9222
  • CHROME_BIN=/usr/bin/chromium-browser
  • CHROME_FLAGS=--no-sandbox,--headless,--disable-gpu,--remote-debugging-port=9222,--hide-scrollbars,--disable-dev-shm-usage
  • REDIS_URL=
  • RABBITMQ_URL=
  • RABBITMQ_CHANNELS=1
  • RABBITMQ_QUEUE=PRERENDER

API

  • To know Service health

    • GET /health
    • curl 'http://localhost:3636/health'
    • { status: "UP" | "DOWN" }
  • Will render URL in Chromium browser then return HTML only the first time. After that, provide HTML content from the cache.

    • GET /render
    • curl 'http://localhost:3636/render?url=http://example.com/'
  • Force reset the cache and render URL in Chromium browser, returns HTML.

    • GET /refresh
    • curl 'http://localhost:3636/refresh?url=http://example.com/'
    • Optional query ignoreResults=true to avoid html results
  • Force reset the cache and render URLs in Chromium browser

    • POST /refresh
    • curl 'http://localhost:3636/refresh' -X 'POST' --data-raw '["not a link","http://example.com/","http://example.com/"]'
  • Will get URL HTML content from the cache.

    • GET /cached
    • curl 'http://localhost:3636/cached?url=http://example.com/'
  • Will clear URL HTML content from the cache.

    • DELETE /cached
    • curl -X 'DELETE' 'http://localhost:3636/cached?url=http://example.com/'

TODO

  • Render SPA page to get HTML
  • Cache HTML
  • Refresh cached HTML
  • Cache unlimited but controlled via API
  • Health status
  • Base environment
  • Docker image
  • Docker for local development
  • Domain limitation
  • Queue for rendering
  • Accumulate Sitemap
  • Different cache technology
  • Different queue technology

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.