Skip to content

Commit f364e56

Browse files
committed
Refactor project structure: rename common/ to shared/ and update imports
- Renamed the `common/` directory to `shared/` to better reflect its purpose. - Updated all relevant import paths across the codebase to use the new `shared/` directory. - Removed obsolete constants and utility files from the `common/` directory to streamline the project structure.
1 parent 8e540b9 commit f364e56

28 files changed

+22
-22
lines changed

PROJECT_STRUCTURE.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ src/
1212
├── database.providers.ts # Database providers
1313
├── main.ts # Entry point
1414
├── ...resources/ # All resource modules directly under `src/`
15-
├── common/ # Common constants, interfaces, and utilities\
15+
├── shared/ # Shared constants, interfaces, and utilities\
1616
scripts/ # Scripts managed by `package.json`
1717
drizzle/ # Drizzle migrations and scripts
1818
drizzle.config.ts # Drizzle configuration
@@ -64,12 +64,12 @@ resource/
6464
- Does **not** export db tables, these are found as schemas inside feature folders
6565
- Does **not** export Drizzle config and migrations, these are found in `drizzle.config.ts` and `drizzle/` (from the root of the project) respectively
6666

67-
#### `common/`
67+
#### `shared/`
6868

69-
Global utilities, middleware, and common concerns.
69+
Global utilities, middleware, and shared concerns.
7070

7171
```plaintext
72-
common/
72+
shared/
7373
├── constants/ # All global constants, grouped by domain
7474
│ ├── auth.constants.ts
7575
│ ├── validation.constants.ts
@@ -85,10 +85,10 @@ common/
8585
```
8686

8787
> [!NOTE]
88-
> The `common/` folder is a catch-all for things that are not specific to a single feature. It's organized by purpose, not by type/domain. That's why it can have both `errors/` (domain) and `utils/` (type) folders.
88+
> The `shared/` folder is a catch-all for things that are not specific to a single feature. It's organized by purpose, not by type/domain. That's why it can have both `errors/` (domain) and `utils/` (type) folders.
8989
9090
> [!WARNING]
91-
> Avoid dumping everything into `common/` by default. If a util, constant, or interface is only used in one feature - keep it inside that feature's folder. Promote it to `common/` only when it's reused.
91+
> Avoid dumping everything into `shared/` by default. If a util, constant, or interface is only used in one feature - keep it inside that feature's folder. Promote it to `shared/` only when it's reused.
9292
9393
> [!TIP]
9494
> Only one `constants/` folder exists across the project - do not spread constants into individual features unless strictly private to that feature.

src/app.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { articlesController } from '@/articles/articles.controller';
22
import { commentsController } from '@/comments/comments.controller';
3-
import { DEFAULT_ERROR_MESSAGE } from '@/common/constants';
3+
import { profilesController } from '@/profiles/profiles.controller';
4+
import { DEFAULT_ERROR_MESSAGE } from '@/shared/constants';
45
import {
56
RealWorldError,
67
formatDBError,
78
formatNotFoundError,
89
formatValidationError,
910
isElysiaError,
10-
} from '@/common/errors';
11-
import { profilesController } from '@/profiles/profiles.controller';
11+
} from '@/shared/errors';
1212
import { tagsController } from '@/tags/tags.controller';
1313
import { usersController } from '@/users/users.controller';
1414
import { swagger } from '@elysiajs/swagger';

src/articles/articles.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { setupArticles } from '@/articles/articles.module';
2-
import { DEFAULT_LIMIT, DEFAULT_OFFSET } from '@/common/constants';
2+
import { DEFAULT_LIMIT, DEFAULT_OFFSET } from '@/shared/constants';
33
import { Elysia, t } from 'elysia';
44
import {
55
ArticleFeedQueryDto,

src/articles/articles.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ArticlesRepository } from '@/articles/articles.repository';
2-
import { RealWorldError } from '@/common/errors';
3-
import { slugify } from '@/common/utils';
42
import type { ProfilesService } from '@/profiles/profiles.service';
3+
import { RealWorldError } from '@/shared/errors';
4+
import { slugify } from '@/shared/utils';
55
import type { TagsService } from '@/tags/tags.service';
66
import { NotFoundError } from 'elysia';
77
import { StatusCodes } from 'http-status-codes';

src/articles/dto/article-feed-query.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
MAX_LIMIT,
55
MIN_LIMIT,
66
MIN_OFFSET,
7-
} from '@/common/constants';
7+
} from '@/shared/constants';
88
import { t } from 'elysia';
99

1010
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import type { articles } from '@/articles/articles.schema';
2-
import type { InferNewRow } from '@/common/interfaces';
2+
import type { InferNewRow } from '@/shared/interfaces';
33

44
export type NewArticleRow = InferNewRow<typeof articles>;

src/articles/mappers/to-new-article-row.mapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { slugify } from '@/common/utils';
1+
import { slugify } from '@/shared/utils';
22
import type { CreateArticleInput, NewArticleRow } from '../interfaces';
33

44
export function toNewArticleRow(

src/auth/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { RealWorldError } from '@/common/errors';
21
import { env } from '@/core/env';
2+
import { RealWorldError } from '@/shared/errors';
33
import type { UserRow } from '@/users/interfaces';
44
import { Type } from '@sinclair/typebox';
55
import { Value } from '@sinclair/typebox/value';

src/comments/comments.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ArticlesService } from '@/articles/articles.service';
2-
import { RealWorldError } from '@/common/errors';
32
import type { ProfilesService } from '@/profiles/profiles.service';
3+
import { RealWorldError } from '@/shared/errors';
44
import { NotFoundError } from 'elysia';
55
import { StatusCodes } from 'http-status-codes';
66
import type { CommentsRepository } from './comments.repository';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { InferNewRow } from '@/common/interfaces';
1+
import type { InferNewRow } from '@/shared/interfaces';
22
import type { comments } from '../comments.schema';
33

44
export type NewCommentRow = InferNewRow<typeof comments>;

0 commit comments

Comments
 (0)