tailor_next_generator
Version:
Tailor Next.js application generator with Styled-components & i18n translation module
23 lines (17 loc) • 756 B
JavaScript
const express = require('express');
const next = require('next');
const nextI18NextMiddleware = require('next-i18next/middleware').default;
const nextI18next = require('./i18n');
const port = process.env.PORT || 3000;
const app = next({ dev: process.env.NODE_ENV !== 'production' });
const handle = app.getRequestHandler();
(async () => {
await app.prepare();
const server = express();
nextI18next.i18n.languages = ['es', 'en'];
nextI18next.i18n.language ? nextI18next.i18n.language = nextI18next.i18n.language : 'es';
server.use(nextI18NextMiddleware(nextI18next));
server.get('*', (req, res) => handle(req, res));
await server.listen(port);
console.log(`> Ready on http://localhost:${port}`); // eslint-disable-line no-console
})();