Skip to content

Commit

Permalink
fix(Elysia 1.0): Breaking changes fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikRoth committed Jul 1, 2024
1 parent 211ab92 commit 252c2d5
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
Binary file modified bun.lockb
Binary file not shown.
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
description = "Bun environment";

inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

outputs =
{ self, nixpkgs }:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem =
f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
in
{
devShells = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.mkShell {
packages = with pkgs; [
bun
nodejs_22
];
};
}
);
};
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"i18next": "^23.5.1",
"bun-plugin-dts": "^0.1.0",
"bun-types": "latest",
"elysia": "^0.7.1",
"elysia": "^1.0.5",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
},
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ export const i18next = (userOptions: Partial<I18NextPluginOptions>) => {
const _instance = options.instance || lib

return new Elysia({ name: 'elysia-i18next', seed: userOptions })
.derive(async () => {
.derive({ as: "global" }, async () => {
if (!_instance.isInitialized) {
await _instance.init(options.initOptions || {})
}
return { i18n: _instance, t: _instance.t }
})
.onBeforeHandle(async ctx => {
.onBeforeHandle({ as: "global" }, async ctx => {
const lng = await options.detectLanguage(ctx)
if (lng) {
await _instance.changeLanguage(lng)
Expand Down

0 comments on commit 252c2d5

Please sign in to comment.