Commit Graph

349 Commits

Author SHA1 Message Date
hykocx 4ddf834990 refactor(api): refactor API module with route definitions and response utilities
Restructure the core API module to improve clarity, consistency, and
maintainability:

- Introduce `defineApiRoutes()` helper for declarative route definitions
  with built-in config validation at startup
- Add `apiSuccess()` / `apiError()` response utilities; enforce their
  use across all handlers (core and modules)
- Move auth enforcement to route definitions (`auth: 'public' | 'user' |
  'admin'`), removing manual auth checks from handlers
- Extract core routes into `core-routes.js`; router now has no knowledge
  of specific features
- Rename `nx-route.js` to `route-handler.js` and update package.json
  export accordingly
- Update ARCHITECTURE.md to reflect new API conventions and point to
  `src/core/api/README.md` for details
2026-04-13 15:13:03 -04:00
hykocx 89741d4460 docs: add project context note in DEV.md 2026-04-13 14:51:43 -04:00
hykocx 260fcfc4f8 docs: extract publication and architecture sections to dedicated files
Move the "Publier le package" section from DEV.md to a new
PUBLICATION.md file, and add references to ARCHITECTURE.md and
PUBLICATION.md in the main DEV.md index. This reduces the size of
DEV.md and improves discoverability by grouping related content
into focused documents.
2026-04-13 13:52:15 -04:00
hykocx 16db807004 docs: rewrite DEV.md with detailed dev and security guidelines
Replace the terse DEV.md with a comprehensive French-language guide
covering code standards, security rules, and the npm publish workflow.

Key changes:
- Expand code principles into readable prose (single responsibility,
  control flow, input validation, promise handling, minimal scope)
- Add concrete security sections: parameterized queries, secret
  management via env vars, dependency auditing, and opaque error
  messages
- Document the full publish procedure (version bump, build, audit,
  npm publish with provenance, git tag)
- Remove the NASA Power of Ten bullet list in favor of actionable,
  project-specific guidelines
2026-04-13 13:34:17 -04:00
hykocx 0e43ea103c docs: update git banner image asset 2026-04-13 13:26:28 -04:00
hykocx 21a5469c0a docs: update git banner image asset 2026-04-13 13:16:58 -04:00
hykocx 4d65a48b01 docs: update banner image and reorder README elements
- Move banner image above the warning notice for better visual hierarchy
- Update git-banner.png with new version
2026-04-13 12:57:53 -04:00
hykocx 8aa97f4782 docs: update README with capitalized title and banner image 2026-04-13 12:10:15 -04:00
hykocx 57dcd2c4d1 chore: bump version to 1.3.12 and expose logger module
- Bump package version from 1.3.11 to 1.3.12
- Add `src/shared/lib/logger.js` to tsup build entry points to expose the logger module as a public export
2026-04-12 22:00:29 -04:00
hykocx 1cd4f322e8 chore: bump version from 1.3.10 to 1.3.11 2026-04-12 21:44:11 -04:00
hykocx e87bd05fa4 refactor: replace console.log with structured logger calls
Replace raw `console.log`/`console.error` calls across CLI, API
handlers, and module files with structured logger functions (`step`,
`done`, `warn`, `fail`) from the shared logger library.

This improves log consistency, readability, and makes it easier to
control output formatting and log levels from a single place.
2026-04-12 21:44:00 -04:00
hykocx dd7c54d913 feat: add modules/storage export and bundle config files
- Add `./modules/storage` package export pointing to `modules.storage.js`
- Add `modules/*/config.js` to tsup build entries for server-only configs
- Add `@zen/core/modules/storage` to external dependencies in tsup config
- Add `src/modules/modules.storage.js` to the second tsup build target
- Update storage handler to import via `@zen/core/modules/storage` alias
- Rename unused `request` param to `_request` in `handleGetFile`
2026-04-12 20:45:55 -04:00
hykocx 35c5ac7ff7 chore: bump version from 1.3.9 to 1.3.10 2026-04-12 20:41:53 -04:00
hykocx d9ba777028 feat(storage): replace hardcoded blog prefix with module-declared public prefixes
Refactor storage access control to use dynamic public prefixes
sourced from `getAllStoragePublicPrefixes()` instead of a hardcoded
`blog` check. Each module can now declare its own public storage
prefixes via `defineModule()` storagePublicPrefixes, making the
system extensible without modifying the core handler.

Also adds a `posts` path handler requiring admin access for private
post types, removes the deprecated `version` API endpoint and its
rate-limit exemption, and minor whitespace/comment cleanup.
2026-04-12 20:41:37 -04:00
hykocx c65d028a20 chore: bump version from 1.3.8 to 1.3.9 2026-04-12 19:09:13 -04:00
hykocx fbe046c5ca refactor(csrf): replace ZEN_APP_URL with NEXT_PUBLIC_URL env vars
Replace the single `ZEN_APP_URL` environment variable with the
existing `NEXT_PUBLIC_URL` and `NEXT_PUBLIC_URL_DEV` variables for
CSRF origin resolution.

- Add `resolveAppUrl()` helper that prefers `NEXT_PUBLIC_URL_DEV`
  in development and falls back to `NEXT_PUBLIC_URL` in production
- Update `passesCsrfCheck()` to use the new helper
- Update error log messages to reference the new variable names
2026-04-12 19:09:00 -04:00
hykocx 33c65d9871 chore: bump version to 1.3.8 and fix module import path
- Bump package version from 1.3.7 to 1.3.8
- Update modules.actions.js import to use package alias
  `@zen/core/core/modules` instead of relative path
2026-04-12 19:05:00 -04:00
hykocx fd228a9e49 chore: bump version from 1.3.6 to 1.3.7 2026-04-12 18:58:33 -04:00
hykocx 3e633e981a docs/refactor: rename getModuleMetadata and update route auth format
- Rename `getModuleMetadata` to `getModuleMetadataGenerator` in registry,
  index, and client exports to clarify its purpose (returns a generator
  function, not a metadata object)
- Add new `getModuleMetadata` and `getMetadataGenerator` exports from
  `modules.metadata.js` for server-side metadata object retrieval
- Update route auth format in docs from `requireAuth`/`requireAdmin`
  flags to a single `auth` field with values: `'admin'`, `'user'`,
  or `'public'`
- Fix `isModuleEnabledInEnv` to replace hyphens with underscores in
  env var names (e.g. `my-module` → `ZEN_MODULE_MY_MODULE`)
- Replace `useState` initializer in `ZenProvider` with `useRef` guard
  to avoid React strict mode double-invocation issues
2026-04-12 18:58:01 -04:00
hykocx c806c8d8d4 docs: replace project structure with dev philosophy section
Replace the project directory tree and PR integration/versioning
sections with a new "Philosophie de développement" section covering
the NASA Power of Ten rules and security-by-design principles.
2026-04-12 18:49:53 -04:00
hykocx 8fd5e361f0 chore: add TypeScript as explicit dev dependency
Add `typescript@^6.0.2` as an explicit devDependency instead of
relying on it being pulled in transitively. This ensures consistent
TypeScript version usage across the project and makes the dependency
requirement clear.
2026-04-12 18:42:45 -04:00
hykocx 8c66ca60d7 chore: bump version to 1.3.6 and remove unused dependencies
- Remove `react-email`, `react-grid-layout` from dependencies
- Remove `tailwindcss`, `@tailwindcss/cli`, `@tailwindcss/postcss`,
  `autoprefixer`, `postcss`, and `typescript` from devDependencies
- Update package-lock.json to reflect dependency removals
- Bump package version from 1.3.5 to 1.3.6
2026-04-12 18:42:10 -04:00
hykocx 8852ce4705 chore: bump version from 1.3.4 to 1.3.5 2026-04-12 18:33:05 -04:00
hykocx 98f1cd9688 fix: harden API security against info leakage and MIME sniffing
- Sanitize route handler errors: only surface known auth messages
  ('Unauthorized', 'Admin access required'); log all other exceptions
  server-side and return a generic 'Internal Server Error' to clients
- Derive profile picture content-type from validated file extension
  instead of attacker-controlled file.type to prevent MIME spoofing
- Always emit explicit Content-Disposition headers on file responses;
  serve known image types as 'inline', force download for all others
  to prevent in-browser rendering of potentially dangerous content
- Add X-Content-Type-Options: nosniff and X-Frame-Options: DENY to
  file response headers
2026-04-12 18:26:33 -04:00
hykocx 49ddcc02fc fix: harden security across CSRF, storage, version, and SQL handling
- **CSRF**: Change missing `ZEN_APP_URL` behavior from bypass (return
  `true`) to enforced deny (return `false`) with an error-level log,
  preventing unauthenticated access when the env var is misconfigured

- **Version endpoint**: Require authentication on the `/version` route
  by passing `request` to `handleVersion`; add session/token validation
  inside the handler so version info is no longer publicly accessible

- **Storage handler**: Enforce a minimum path depth of 3 segments for
  public blog file access to prevent unintentional root-prefix exposure;
  strip raw storage error messages (bucket names, keys) from all client
  responses, logging full details server-side only

- **SQL injection hardening**: Wrap the whitelisted `sortColumn`
  identifier in double-quotes in the `handleListUsers` query to enforce
  identifier boundaries and prevent any edge case from being interpreted
  as SQL syntax

- **Misc**: Improve log clarity for orphaned profile picture deletion
  failures; add inline comments explaining security rationale throughout
2026-04-12 17:49:12 -04:00
hykocx 7fc14fece7 chore: bump version from 1.3.3 to 1.3.4 2026-04-12 17:40:52 -04:00
hykocx 8209503395 feat(api): add CSRF protection and rate limiting to routers
- Add `passesCsrfCheck()` to both `router.js` and `dynamic-router.js`
  to block cross-site request forgery on state-mutating methods
  (POST/PUT/PATCH/DELETE) by validating Origin/Referer headers against
  `ZEN_APP_URL`
- Apply global IP-based rate limiting in `dynamic-router.js` mirroring
  the policy already present in `router.js`; exempt health and version
  GET endpoints from throttling
- Sanitize 404 response in `dynamic-router.js` to prevent route
  structure enumeration
- Strip internal error details from user-facing error messages (e.g.
  profile picture deletion) to avoid information leakage
2026-04-12 17:40:34 -04:00
hykocx 2017f9791b docs: remove zen-setup CLI and simplify installation guide
- Remove `zen-setup` binary from package.json and package-lock.json
- Replace manual setup steps with `npx @zen/start` CLI command
- Simplify INSTALL.md by reducing steps from 6 to 4
- Update DEV.md to reflect removal of zen-setup from CLI scripts
- Fix relative path to `.env.example` in documentation
2026-04-12 17:07:33 -04:00
hykocx 6e33726862 refactor: remove ZEN_DESCRIPTION env variable usage
Remove the `ZEN_DESCRIPTION` environment variable from `.env.example`
and its usage in `generateMetadata`. The description field is no longer
needed in the default metadata configuration.
2026-04-12 16:09:03 -04:00
hykocx 06e4d8c963 refactor: remove unused files 2026-04-12 16:05:04 -04:00
hykocx a57bf3607b docs(posts): add API and Next.js integration documentation
Add three documentation files for the posts module:
- `api.md`: public API reference (list, slug, categories, images)
- `admin-api.md`: admin API reference with all CRUD endpoints
- `integration.md`: Next.js integration examples with code snippets
2026-04-12 15:59:37 -04:00
hykocx 66314481a0 docs(posts): simplify README by removing verbose examples and details 2026-04-12 15:59:11 -04:00
hykocx 881aa75d2a docs(posts): simplify README by removing verbose examples 2026-04-12 15:58:58 -04:00
hykocx 27a5887527 docs: add development and security links to README 2026-04-12 15:29:16 -04:00
hykocx b8a6b3e86c docs: update org name from hykocx to zen and expand DEV guide
- Replace `hykocx` with `zen`/`HYKO` in LICENSE copyright notices
- Update npm registry scope from `@hykocx` to `@zen` in INSTALL.md
- Update npm auth token config path to use `zen` org in DEV.md
- Add project structure overview to DEV.md
- Add contribution standards section referencing GUIDE.md and REDACTION.md
- Add semver versioning bump reference table to DEV.md
2026-04-12 15:13:11 -04:00
hykocx 81172bda94 chore: rename package from @hykocx/zen to @zen/core
Update all references across source files, documentation, and
configuration to reflect the new package scope and name. This includes
updating `.npmrc` registry config, install instructions, module
examples, and all import path comments throughout the codebase.
2026-04-12 15:09:26 -04:00
hykocx 30067a699d refactor: remove old modules dashboard exports from package.json 2026-04-12 14:51:15 -04:00
hykocx 134008daea chore: bump version to 1.3.2 2026-04-12 14:42:01 -04:00
hykocx 1b53ba8d58 refactor: remove setup feature from build exports and config
Removes the `./setup` export entry from `package.json` and the
corresponding `src/features/setup/index.js` entry point from
`tsup.config.js`, eliminating the standalone setup feature module
from the public API and build output.
2026-04-12 14:40:34 -04:00
hykocx 390133808b refactor: consolidate CLI entry points into dedicated cli/ directory
Move `database` and `setup` CLI scripts from their respective feature
directories into a unified `src/cli/` directory. Update `tsup.config.js`
build entries and `package.json` bin paths to reflect the new locations.
2026-04-12 14:39:17 -04:00
hykocx 54c4ad058d docs: translate INSTALL.md to French and add npm registry step
- Translate all installation instructions from English to French
- Add new step to configure the npm registry with a `.npmrc` file
- Renumber steps accordingly (now 6 steps instead of 5)
2026-04-12 14:37:33 -04:00
hykocx c33383adf7 docs: translate posts README to French and update language guide
- Rewrite content with clearer structure, adding env variable examples and improving field type descriptions
2026-04-12 14:32:21 -04:00
hykocx 99a56d2c39 feat(modules): add external module registration and defineModule support
- Add `./modules/define` export path pointing to `defineModule.js`
- Implement `registerExternalModules()` to handle modules passed via `zen.config.js`, with env var gating (`ZEN_MODULE_<NAME>=true`)
- Extract `buildAdminConfig()` helper to consolidate admin navigation/page config building
- Refactor `loadModuleConfig()` to use `buildAdminConfig()` and simplify public routes check
- Improve `initializeModuleTables()` to gracefully skip modules without `db.js` instead of erroring
- Update module discovery JSDoc to reflect external module registration support
2026-04-12 13:39:56 -04:00
hykocx 4983a24325 refactor: remove clients, invoice, and nuage module integrations
Strips out built-in clients, invoice, and nuage modules from core
handlers, module initializers, and action registries. This cleans up
hardcoded module dependencies, leaving only the posts module as a
reference implementation for the modular architecture.
2026-04-12 13:18:21 -04:00
hykocx 024d6e37e6 revert: fix package version from 1.4.0 to 1.3.1
Reverts the package version in package-lock.json from 1.4.0 back to 1.3.1
2026-04-12 13:07:59 -04:00
hykocx 2f9288e8c5 test: update npm version 2026-04-12 12:53:51 -04:00
hykocx 46e27b746c docs: delete copy readme 2026-04-12 12:52:02 -04:00
hykocx 65ae3c6788 chore: import codes 2026-04-12 12:50:14 -04:00
hykocx 4bcb4898e8 Initial commit 2026-04-12 12:49:04 -04:00