Skip to content

A middleware to serve static content for Diet.js. It can serve all kinds of files and be used as a CDN solution.

License

Notifications You must be signed in to change notification settings

st235/diet-static-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diet-static-middleware

npm version npm downloads dependencies license

A middleware to serve static content for Diet.js. It can serve all kinds of files and be used as a CDN solution. Works entirely using streams, and doesn't blow your RAM. Caching and 'powered by' headers can be configured using options.

Install

npm install diet-static-middleware

Usage

'use strict';

const server = require('diet');
const app = server().listen(8000);

const static = require('diet-static-middleware')({
path: app.path + '/path/to/your/static/folder'
});

app.footer(static);

Options

User options, that configure diet-static-middleware.

require('diet-static-middleware')({
    path: app.path+'/path/to/your/static/folder', // path to folder where you store files
    cache: 'public', // type of cache. May be public or private
    expires: 604800000, // expires time
    powered: 'diet-static-uniqlab', // powered by (for security)
    server: 'uniqlab-nodejs' // server (for security)
});

Finally

Every route associated with file on storage

// http://localhost:8000/nation.json	--> `/path/to/your/static/folder/nation.json`
// http://localhost:8000/favicon.ico	--> `/path/to/your/static/folder/favicon.ico`
// http://localhost:8000/android/app-realise.apk	--> `/path/to/your/static/folder/android/app-realise.apk`
// http://localhost:8000/styles/global.css	--> `/path/to/your/static/folder/styles/global.css`
// http://localhost:8000/company/logo.png	--> `/path/to/your/static/folder/company/logo.png`

License

(The MIT License)

Copyright (c) 2016 Alexander Dadukin & Andrey Pavlov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A middleware to serve static content for Diet.js. It can serve all kinds of files and be used as a CDN solution.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published