Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pr-render-static

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pr-render-static

@priestine/routing module for rendering static files

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@priestine/routing Render Static Module

The pr-render-static module allows rendering static files using @priestine/routing.

Installation

yarn add @priestine/routing pr-render-static

Usage

It's as easy as registering a new GET route and assigning it RenderStatic.from(/* static file directory */) which returns an array of middleware that will search for a file in the directory provided as the argument (this is relative to your package.json), set required MIME type and fire the response containing the data. If the file does not exist, it will set status code to 404 and end the response with text/plain Content-Type header.

Example

import { HttpRouter } from '@priestine/routing';
import { RenderStatic } from 'pr-render-static';

const router = HttpRouter.empty()
  .get(/^\/static\/.*/, RenderStatic.from('static'))
;

NOTE

It is recommended to include RenderStatic as the very last item in your router in case static files are not rendered on a specific route (e.g. when you set up RenderStatic for /^.*$/) so that it is referred to as the last resort.

Keywords

FAQs

Package last updated on 13 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc