Code Monkey home page Code Monkey logo

connect-favicons's Introduction

Connect Favicons

Serve site icons (favicon.ico and apple-touch-icon.png and all its flavours) quickly and from any directory.

Install

npm install --save git://github.com/theworkers/connect-favicons.git

Recognised icon filenames

  • favicon.ico
  • favicon.png
  • apple-touch-icon.png
  • apple-touch-icon-precomposed.png
  • apple-touch-icon-57x57.png
  • apple-touch-icon-57x57-precomposed.png
  • apple-touch-icon-72x72.png
  • apple-touch-icon-72x72-precomposed.png
  • apple-touch-icon-76x76.png
  • apple-touch-icon-76x76-precomposed.png
  • apple-touch-icon-114x114.png
  • apple-touch-icon-114x114-precomposed.png
  • apple-touch-icon-120x120.png
  • apple-touch-icon-120x120-precomposed.png
  • apple-touch-icon-144x144.png
  • apple-touch-icon-144x144-precomposed.png
  • apple-touch-icon-152x152.png
  • apple-touch-icon-152x152-precomposed.png
  • apple-touch-icon-180x180.png
  • apple-touch-icon-180x180-precomposed.png
  • favicon-16x16.png
  • favicon-32x32.png
  • favicon-128x128.png
  • favicon-256x256.png
  • mstile-150x150.png
  • safari-pinned-tab.svg

Usage

Add connect-favicons to your middleware stack before everything else. The whole point here is to serve favicon.ico and apple-touch-icon.png (et al.) quickly, without involving any routing.

In this case, you may have all your site icons, including favicon.ico in /public/img/icons:

app.use(favicons(__dirname + '/public/img/icons'));

Now any request to the example.com/favicon.ico or example.com/apple-touch-icon.png will be served by Connect Favicons, reading from the folder you specified.

Example

var http     = require('http');
var path     = require('path');
var express  = require('express');
var favicons = require('connect-favicons');

var app = express();

// Middleware stack
app.use(favicons(__dirname + '/public/img/icons'));
app.use(express.static(path.join(__dirname, '/public')));

http.createServer(app).listen(3000, function(){
    console.log("Express server listening on port " + 3000);
});

connect-favicons's People

Contributors

kfarr avatar rc1 avatar tmslnz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

connect-favicons's Issues

Returns 500 instead of 404

Hi,
Thanks for that middleware.

We moved from 0.0.4 to 0.1.4 this week and we started getting 500 on touch icons.
Turns out that errno is not always 34 on missing filenames:
https://github.com/theworkers/connect-favicons/blob/master/lib/favicons-middleware.js#L63

eg, on Windows

{ [Error: ENOENT: no such file or directory, open 'C:\users\...\public\images\icons\apple-touch-icon-precomposed.png']
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\users\\...\\public\\images\\icons\\apple-touch-icon-precomposed.png' }
Error: ENOENT: no such file or directory, open 'C:\users\...\public\images\icons\apple-touch-icon-precomposed.png'
    at Error (native)

We ended up adding the missing -precomposed files.

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.