1.0.3 • Published 5 years ago

@chatoo2412/reserved-filenames v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

CircleCI

reserved-filenames

All filenames reserved by browsers, bots, etc.

Useful to prevent weird 404 errors.

Install

npm install @chatoo2412/reserved-filenames

How to Use

// server.js

import Koa from 'koa';
import serve from 'koa-static';
import reservedFilenames from '@chatoo2412/reserved-filenames';

const server = new Koa();

server.use(serve('path/to/static'));

server.use((ctx, next) => {
  if (reservedFilenames.includes(ctx.path.substring(1))) {
    ctx.throw(404);

    return;
  }

  next();
});

server.use(/* ... */);

server.listen(/* ... */);

Contributing

Welcome!