Skip to content

Commit

Permalink
refactor(server): switched to lodash-es to reduce bundle and docker i…
Browse files Browse the repository at this point in the history
…mage (#17)
  • Loading branch information
CorentinTh authored Aug 24, 2024
1 parent be60f0d commit 1f18546
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/app-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"date-fns": "^3.6.0",
"figue": "^2.0.0",
"hono": "^4.5.8",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"pino": "^9.3.2",
"ulid-workers": "^2.1.0",
"unstorage": "^1.10.2",
Expand All @@ -40,7 +40,7 @@
"devDependencies": {
"@antfu/eslint-config": "^2.27.0",
"@cloudflare/workers-types": "^4.20240821.1",
"@types/lodash": "^4.17.7",
"@types/lodash-es": "^4.17.12",
"dotenv": "^16.4.5",
"esbuild": "^0.23.1",
"eslint": "^9.9.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/app-server/src/modules/notes/notes.repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Storage } from 'unstorage';
import { addSeconds, isBefore } from 'date-fns';
import _ from 'lodash';
import { omit } from 'lodash-es';
import { generateNoteId } from './notes.models';
import { createNoteNotFoundError } from './notes.errors';

Expand Down Expand Up @@ -51,7 +51,7 @@ function createNoteRepository({ storage }: { storage: Storage }) {
}

return {
note: _.omit(note, 'expirationDate'),
note: omit(note, 'expirationDate'),
};
},
};
Expand Down
6 changes: 3 additions & 3 deletions packages/app-server/src/modules/shared/errors/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StatusCode } from 'hono/utils/http-status';
import _ from 'lodash';
import { get, isError, toString } from 'lodash-es';

export { createError, createErrorFactory, isCustomError };

Expand All @@ -24,7 +24,7 @@ export class CustomError extends Error {
super(message);

this.code = code;
this.cause = _.isError(cause) ? cause : new Error(_.toString(cause));
this.cause = isError(cause) ? cause : new Error(toString(cause));
this.statusCode = statusCode;
this.documentationUrl = documentationUrl;
this.isInternal = isInternal;
Expand All @@ -42,5 +42,5 @@ function createErrorFactory(baseOption: ErrorOptions) {
}

function isCustomError(error: unknown): error is CustomError {
return _.get(error, 'isCustomError') === true;
return get(error, 'isCustomError') === true;
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

0 comments on commit 1f18546

Please sign in to comment.