@eeplatform/core 1.8.7 → 1.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,26 +15,24 @@ jobs:
15
15
  publish:
16
16
  if: ${{ github.event.workflow_run.conclusion == 'success' }}
17
17
  runs-on: ubuntu-latest
18
- environment: production
19
18
  steps:
20
19
  - uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0
21
22
 
22
23
  - uses: actions/setup-node@v4
23
24
  with:
24
25
  node-version: 20.x
25
- cache: "yarn" # Use yarn for caching
26
- cache-dependency-path: yarn.lock # Cache Yarn lockfile
27
-
28
- - run: yarn install --immutable # Install dependencies with immutable lockfile
26
+ cache: "yarn"
27
+ cache-dependency-path: yarn.lock
29
28
 
30
- - name: Create .npmrc for publishing
31
- run: |
32
- echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' > ~/.npmrc
29
+ - run: yarn install --immutable
33
30
 
34
31
  - name: Create Release Pull Request or Publish
35
32
  id: changesets
36
33
  uses: changesets/action@v1
37
34
  with:
38
- publish: yarn release # Use yarn for publishing
35
+ publish: yarn release
39
36
  env:
40
37
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eeplatform/core
2
2
 
3
+ ## 1.8.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 6a72a1c: Update dependencies
8
+
3
9
  ## 1.8.7
4
10
 
5
11
  ### Patch Changes
package/CLAUDE.md ADDED
@@ -0,0 +1,106 @@
1
+ # server-core-module (`@goweekdays/core`)
2
+
3
+ Shared server module exported as a package consumed by all app servers.
4
+ Built with Express + MongoDB (Atlas) + TypeScript.
5
+
6
+ ## Resource Layer Pattern
7
+
8
+ Each resource lives under `src/resources/<resource-name>/` and follows this structure:
9
+
10
+ ```
11
+ resource-name/
12
+ resource.model.ts # Types and validation schema
13
+ resource.repository.ts # Direct database interaction
14
+ resource.service.ts # Business logic (optional — see below)
15
+ resource.controller.ts # API request handler
16
+ index.ts # Barrel export
17
+ ```
18
+
19
+ ### `.model.ts`
20
+
21
+ Defines the TypeScript type and Joi validation schema for the resource. This is the source of truth for the shape of the data.
22
+
23
+ ### `.repository.ts`
24
+
25
+ Contains all functions that directly interact with the database (MongoDB). No business logic here — only reads and writes.
26
+
27
+ ### `.service.ts`
28
+
29
+ Builds business logic by composing repository functions and third-party integrations (e.g. hashing, email, S3, transactions). Never accesses the database directly — all DB interaction goes through the repository. **This layer is optional** — if a resource only needs basic CRUD with no business logic, a service file is not required.
30
+
31
+ ### `.controller.ts`
32
+
33
+ Handles incoming API requests. Validates the request input, then delegates to the service layer if business logic exists, or calls the repository directly if the resource has no service.
34
+
35
+ ### `index.ts`
36
+
37
+ Re-exports all layers so consumers can import from the resource folder directly.
38
+
39
+ ```typescript
40
+ export * from "./user.model";
41
+ export * from "./user.repository";
42
+ export * from "./user.service";
43
+ export * from "./user.controller";
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Naming Conventions
49
+
50
+ | Layer | Pattern | Example |
51
+ | ---------- | --------------------------- | ---------------------------------------------------- |
52
+ | File | `<resource>.<layer>.ts` | `user.model.ts`, `finance.journal.config.service.ts` |
53
+ | Type | `T<Resource>` | `TUser`, `TJobPost` |
54
+ | Schema | `schema<Resource>` | `schemaUser`, `schemaJobPost` |
55
+ | Model fn | `model<Resource>()` | `modelUser()`, `modelJobPost()` |
56
+ | Repository | `use<Resource>Repo()` | `useUserRepo()`, `useOrgRepo()` |
57
+ | Service | `use<Resource>Service()` | `useUserService()`, `useOrgService()` |
58
+ | Controller | `use<Resource>Controller()` | `useUserController()` |
59
+
60
+ Multi-word resource names use dot notation in file names: `finance.journal.config.model.ts`, `job.post.repository.ts`.
61
+
62
+ ---
63
+
64
+ ## Error Handling
65
+
66
+ Always use the typed error classes from `@eeplatform/nodejs-utils` — never throw a generic `new Error()`.
67
+
68
+ - `BadRequestError` — invalid input or a violated business rule
69
+ - `NotFoundError` — resource does not exist
70
+ - `InternalServerError` — unexpected DB or system failure
71
+ - `AppError` — base class; use `instanceof AppError` in catch blocks to re-throw typed errors as-is
72
+
73
+ ---
74
+
75
+ ## Controller Input Extraction
76
+
77
+ Validate the entire `req.body` against a Joi schema to ensure no unexpected keys are passed. Extract only the fields you need after validation.
78
+
79
+ 1. Define a Joi schema that describes exactly the expected shape
80
+ 2. Validate `req.body` (or `req.params` / `req.query`) against it — reject if invalid
81
+ 3. Destructure only the needed fields from the validated result
82
+ 4. Delegate to the service or repository
83
+
84
+ This prevents unexpected or extra fields from leaking into the database.
85
+
86
+ ---
87
+
88
+ ## Transactions
89
+
90
+ Use a MongoDB session whenever a service function writes to more than one collection. The pattern is always:
91
+
92
+ 1. Start session and transaction
93
+ 2. Pass `session` down to every repo call
94
+ 3. Commit on success, abort on error, and always end the session in `finally`
95
+
96
+ Transactions belong in the service layer only — never in a controller or repository.
97
+
98
+ ---
99
+
100
+ ## What Not To Do
101
+
102
+ - **No business logic in controllers** — controllers only handle HTTP input/output and delegate
103
+ - **No direct DB access in controllers or services** — all DB interaction belongs in the repository only
104
+ - **No generic `Error` throws** — use the typed error classes above
105
+ - **No Zod** — validation is done with Joi throughout this module
106
+ - **No extra fields into the DB** — always validate the full request body before using any of it
package/dist/index.js CHANGED
@@ -1878,7 +1878,7 @@ function useVerificationService() {
1878
1878
  to: email,
1879
1879
  subject: "Member Invite",
1880
1880
  html: emailContent2,
1881
- from: "EEPlatform"
1881
+ from: `"EEPlatform" <support@goweekdays.com>`
1882
1882
  }).catch((error) => {
1883
1883
  import_nodejs_utils9.logger.log({
1884
1884
  level: "error",
@@ -1900,7 +1900,7 @@ function useVerificationService() {
1900
1900
  to: email,
1901
1901
  subject: "User Invite",
1902
1902
  html: emailContent,
1903
- from: "EEPlatform"
1903
+ from: `"EEPlatform" <support@goweekdays.com>`
1904
1904
  }).catch((error) => {
1905
1905
  import_nodejs_utils9.logger.log({
1906
1906
  level: "error",
@@ -1934,7 +1934,7 @@ function useVerificationService() {
1934
1934
  mailer.sendMail({
1935
1935
  to: email,
1936
1936
  subject: "Forget Password",
1937
- from: "EEPlatform",
1937
+ from: `"EEPlatform" <support@goweekdays.com>`,
1938
1938
  html: emailContent
1939
1939
  }).catch((error) => {
1940
1940
  import_nodejs_utils9.logger.log({
@@ -2129,7 +2129,7 @@ function useVerificationService() {
2129
2129
  to: email,
2130
2130
  subject: "Sign Up Verification",
2131
2131
  html: emailContent,
2132
- from: "EEPlatform"
2132
+ from: `"EEPlatform" <support@goweekdays.com>`
2133
2133
  }).catch((error) => {
2134
2134
  import_nodejs_utils9.logger.log({
2135
2135
  level: "error",