Skip to content

18next-http-middleware in fastify #39

@Rafael-006

Description

@Rafael-006

🐛 Bug Report

I am using this middleware in fastify application with typescript.

When i do compilation using tsc for my application, the type definition of 18next-http-middleware in node_modules throws error as mentioned below,

node_modules/i18next-http-middleware/index.d.ts:9:8 - error TS2307: Cannot find module 'express-serve-static-core' or its corresponding type declarations.

9 } from "express-serve-static-core";

Expected behavior

I've registered this middleware in fastify and typescript configuration are done which includes node_modules to the outDir.

import i18next from 'i18next';
import Backend from 'i18next-fs-backend';
import middleware from 'i18next-http-middleware';
import fastify from 'fastify';

i18next
  .use(Backend)
  .use(middleware.LanguageDetector)
  .init({
    fallbackLng: 'en',
    backend: {
      loadPath: './locales/{{lng}}/translation.json'
    }
  });

fastify.register(middleware.plugin, {
    i18next
  });

fastify();

When i run tsc, expected the compilation to run successfully and output the js files in outDir.

Your Environment

  • runtime version: node v14.17.0
  • i18next version: 20.3.0
  • i18next-fs-backend: 1.1.1
  • i18next-http-middleware: 3.1.3
  • os: Ubuntu 20.04.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions