This PR is bundling a bunch of things that I wanted to apply on the repo to make it a little more up-to-date, and hopefully easier to work with:
Translation of CoffeeScript files to Javascript ES6
Update of the build pipeline to Gulp/Babel
Linting with ESLint + AirBnb codestyle
A dev task (as default when running gulp) to watch, lint and transpile
The source still has no dependency and can be run on Node >= 0.8 but the dev environment will work with Node >= 4 (6 preferred).
Upgrade of all dev dependencies.
Publishing
Open to suggestions - I'm planning on publishing a 1.0.0beta version of the package first, before making it official and stable. I'm not too worried but I could have missed something. 🤞
TODO
[ ] Changelog
[ ] Bump the version
Review
Tests have been ported to JS as well, but if you could make sure that the source files (especially the main src/index.js) doesn't introduce regression, that would be fantastic.
Any additional tests are very welcome as well.
Testing
Clone the repo and checkout this branch. I personally linked the local branch and installed it in another repo to test imports were still working.
git clone https://github.com/florrain/locale.git
cd locale
git checkout repo-upgrade
npm install
npm link
cd ../express-application
npm link locale # install local version of the package
Fire up an Express application
Register the middleware
Define a route to print the locale
Send a request with the "Accept-Language" header and check it is working as expected.
Something like this:
import http from 'http';
import express from 'express';
import locale from 'locale';
const app = express();
app.server = http.createServer(app);
app.use(locale(['en', 'de'], 'en'));
app.get('/', function (req, res) {
res.json({ headers: req.headers, locale: req.locale });
});
app.server.listen(process.env.PORT || config.port);
console.log(`Started on port ${app.server.address().port}`);
Overview
This PR is bundling a bunch of things that I wanted to apply on the repo to make it a little more up-to-date, and hopefully easier to work with:
gulp
) to watch, lint and transpilePublishing
Open to suggestions - I'm planning on publishing a 1.0.0beta version of the package first, before making it official and stable. I'm not too worried but I could have missed something. 🤞
TODO
Review
Tests have been ported to JS as well, but if you could make sure that the source files (especially the main src/index.js) doesn't introduce regression, that would be fantastic. Any additional tests are very welcome as well.
Testing
Something like this: