@tajawalae/web-server-middleware
v1.9.7
Published
Web server middleware
Downloads
72
Readme
web-server-middleware
Base set of functions to be user to generate the necessary config for a web-app-server. Whether you're using express, koa, restify or plain node-http server, these utils will get you up to speed to work on your product of choice.
What's in the box?
Config: Generate the necessary configuration for each POS and Brand based on the request URL.
Device: Detect device type and media based on user-agent
Language: Detect language and direction based on path | cookie | param | config
Translation: Fetch translation if required
Currency: Fetch translation if required
Usage
const express = require('express');
const { middleware } = require('@tajawalae/web-server-middleware');
const app = express();
// Application middlewares
app.use([
middleware.config,
middleware.device,
middleware.language,
middleware.translation,
middleware.currency
]);
app.listen(PORT, () => {
console.log(`server is running in ${NODE_ENV} mode`);
console.log(`listening on http://localhost:${PORT}`);
});
[TODO]
- [x] Translation middleware
- [ ] Add Code Style checks for the project (eslint + husky)
- [x] Local host dynamic config
- [x] Replace
envId
withdomain
- [x] Replace
lang
withlanguage