create-berna-stencil 1.0.45 → 1.0.47

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.
package/.eleventy.js CHANGED
@@ -4,7 +4,7 @@ const Image = require("@11ty/eleventy-img");
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
 
7
- const OUTPUT_DIR = "c:/laragon/www/Berna-Stencil-out";
7
+ const OUTPUT_DIR = "out";
8
8
 
9
9
  module.exports = function (eleventyConfig) {
10
10
 
@@ -2,9 +2,13 @@
2
2
  // CSS MODULES IMPORTS
3
3
  //==========================
4
4
 
5
+ // Use @use with a namespace to avoid framework variable conflicts:
6
+ // Example: root.$primary
5
7
  @use "../modules/root" as root;
6
8
 
9
+ // This global module contains the import framework, necessary modules for each page and any other common styles
7
10
  @import "../modules/global";
11
+
8
12
  // Import any other module you need by import down here
9
13
  @import "../modules/notification";
10
14
 
@@ -12,6 +16,8 @@
12
16
  // PAGE CUSTOM CSS RULES
13
17
  //==========================
14
18
 
19
+ // Add any custom rule specific to this page below
20
+ // These rules override the framework and module styles
15
21
  // body {
16
22
  // background-color: root.$primary;
17
23
  // }
package/bin/create.js CHANGED
@@ -15,7 +15,7 @@ const COPY_TARGETS = [
15
15
 
16
16
  const PROJECT_PACKAGE = {
17
17
  name: path.basename(targetDir),
18
- version: '1.0.37',
18
+ version: '1.0.47',
19
19
  private: true,
20
20
  scripts: {
21
21
  "build:css": "sass src/frontend/scss:out/css --no-source-map --style=compressed --quiet",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-berna-stencil",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "Eleventy boilerplate with per-page SCSS/JS pipeline, esbuild bundling, multi-framework CSS support and a built-in page management CLI",
5
5
  "keywords": [
6
6
  "eleventy",
@@ -60,12 +60,12 @@
60
60
  "sass": "^1.77.0"
61
61
  },
62
62
  "scripts": {
63
- "build:css": "sass src/frontend/scss:c:/laragon/www/Berna-Stencil-out/css --no-source-map --style=compressed --quiet",
64
- "build:js": "esbuild \"src/frontend/js/pages/*.js\" --bundle --outdir=c:/laragon/www/Berna-Stencil-out/js/pages --minify",
63
+ "build:css": "sass src/frontend/scss:out/css --no-source-map --style=compressed --quiet",
64
+ "build:js": "esbuild \"src/frontend/js/pages/*.js\" --bundle --outdir=out/js/pages --minify",
65
65
  "build:11ty": "eleventy",
66
66
  "build": "npm run build:css && npm run build:js && npm run build:11ty",
67
- "serve:css": "sass --watch src/frontend/scss:c:/laragon/www/Berna-Stencil-out/css --no-source-map --quiet",
68
- "serve:js": "esbuild \"src/frontend/js/pages/*.js\" --bundle --outdir=c:/laragon/www/Berna-Stencil-out/js/pages --watch",
67
+ "serve:css": "sass --watch src/frontend/scss:out/css --no-source-map --quiet",
68
+ "serve:js": "esbuild \"src/frontend/js/pages/*.js\" --bundle --outdir=out/js/pages --watch",
69
69
  "serve:11ty": "eleventy --serve --quiet",
70
70
  "clean": "node _tools/cleanOutput.js",
71
71
  "serve": "npm run clean && concurrently \"npm run serve:11ty\" \"npm run serve:css\" \"npm run serve:js\"",
@@ -3,6 +3,7 @@
3
3
  declare(strict_types=1);
4
4
 
5
5
  define('CORE_ACCESS', true);
6
+ define('CORE_PATH', __DIR__);
6
7
 
7
8
  /**
8
9
  * Load dependencies and initial configuration.
@@ -87,15 +88,7 @@ if (!$endpointFile) {
87
88
  header('Content-Type: application/json; charset=UTF-8');
88
89
  header('Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS');
89
90
  header('Access-Control-Allow-Headers: Content-Type, X-Api-Key');
90
-
91
- $allowedOrigins = array_filter(array_map('trim', explode(',', $config['CORS_ALLOWED_ORIGINS'] ?? '')));
92
- $origin = $_SERVER['HTTP_ORIGIN'] ?? '';
93
-
94
- if (in_array($origin, $allowedOrigins, true) || in_array('*', $allowedOrigins, true)) {
95
- header("Access-Control-Allow-Origin: $origin");
96
- } else {
97
- header("Access-Control-Allow-Origin: " . ($allowedOrigins[0] ?? ''));
98
- }
91
+ header('Access-Control-Allow-Origin: *');
99
92
 
100
93
  if ($method === 'OPTIONS') {
101
94
  http_response_code(204);
@@ -107,8 +100,11 @@ if ($method === 'OPTIONS') {
107
100
  // =====================================================
108
101
 
109
102
  if ($isProtected) {
110
- $apiKey = $_SERVER['HTTP_X_API_KEY'] ?? '';
111
- $validKey = $config['API_KEY'] ?? '';
103
+ $relPath = str_replace($baseProtected, '', $endpointFile);
104
+ $relPath = str_replace('.php', '', str_replace('\\', '/', $relPath));
105
+
106
+ $validKey = $config['ENDPOINT_KEYS'][$relPath] ?? $config['API_KEY'] ?? '';
107
+ $apiKey = $_SERVER['HTTP_X_API_KEY'] ?? '';
112
108
 
113
109
  if ($validKey === '' || $apiKey !== $validKey) {
114
110
  Response::error('Unauthorized. X_API_KEY is incorrect or missing', 401);
@@ -3,9 +3,13 @@ declare(strict_types=1);
3
3
 
4
4
 
5
5
  // 2. Richiamo il tuo modulo Response e il Modello
6
- require_once __DIR__ . '/../../_core/modules/Response.php';
6
+ require_once CORE_PATH . '/modules/Response.php';
7
7
  require_once __DIR__ . '/../../database/models/User.php';
8
8
 
9
+ //
10
+ // Your protected endpoint logic here. You can access route parameters in $requestParams array
11
+ //
12
+
9
13
  $user = new User();
10
14
  $id = isset($requestParams[0]) ? (int)$requestParams[0] : null;
11
15
  $input = json_decode(file_get_contents('php://input'), true) ?? [];
@@ -1,17 +1,17 @@
1
1
  <?php
2
2
  declare(strict_types=1);
3
3
 
4
- require_once __DIR__ . '/../../_core/modules/Response.php';
4
+ require_once CORE_PATH . '/modules/Response.php';
5
5
 
6
6
  if ($method !== 'GET') {
7
7
  Response::error('Method not allowed', 405);
8
8
  }
9
9
 
10
+ //
11
+ // Your protected endpoint logic here. You can access route parameters in $requestParams array
12
+ //
13
+
10
14
  Response::success([
11
15
  'message' => 'Protected endpoint is working',
12
16
  'params' => $requestParams,
13
- ]);
14
-
15
- Response::error([
16
- 'message' => 'Error text',
17
17
  ]);
@@ -1,13 +1,17 @@
1
1
  <?php
2
2
  declare(strict_types=1);
3
3
 
4
- require_once __DIR__ . '/../../../_core/modules/Response.php';
4
+ require_once CORE_PATH . '/modules/Response.php';
5
5
  require_once __DIR__ . '/../../../database/models/User.php';
6
6
 
7
7
  if ($method !== 'POST') {
8
8
  Response::error('Method not allowed', 405);
9
9
  }
10
10
 
11
+ //
12
+ // Your protected endpoint logic here. You can access route parameters in $requestParams array
13
+ //
14
+
11
15
  $input = json_decode(file_get_contents('php://input'), true) ?? [];
12
16
 
13
17
  $email = trim(filter_var($input['email'] ?? '', FILTER_SANITIZE_EMAIL));
@@ -1,13 +1,18 @@
1
1
  <?php
2
2
  declare(strict_types=1);
3
3
 
4
- require_once __DIR__ . '/../../../_core/modules/Response.php';
4
+ require_once CORE_PATH . '/modules/Response.php';
5
5
  require_once __DIR__ . '/../../../database/models/User.php';
6
6
 
7
7
  if ($method !== 'POST') {
8
8
  Response::error('Method not allowed', 405);
9
9
  }
10
10
 
11
+ //
12
+ // Your protected endpoint logic here. You can access route parameters in $requestParams array
13
+ //
14
+
15
+
11
16
  $input = json_decode(file_get_contents('php://input'), true) ?? [];
12
17
 
13
18
  $nickname = htmlspecialchars(strip_tags(trim($input['nickname'] ?? '')));
@@ -1,17 +1,17 @@
1
1
  <?php
2
2
  declare(strict_types=1);
3
3
 
4
- require_once __DIR__ . '/../../_core/modules/Response.php';
4
+ require_once CORE_PATH . '/modules/Response.php';
5
5
 
6
6
  if ($method !== 'GET') {
7
7
  Response::error('Method not allowed', 405);
8
8
  }
9
9
 
10
+ //
11
+ // Your protected endpoint logic here. You can access route parameters in $requestParams array
12
+ //
13
+
10
14
  Response::success([
11
15
  'message' => 'Public endpoint is working',
12
16
  'params' => $requestParams,
13
- ]);
14
-
15
- Response::error([
16
- 'message' => 'Error text',
17
17
  ]);
@@ -2,9 +2,15 @@
2
2
  declare(strict_types=1);
3
3
 
4
4
  return [
5
- 'API_KEY' => 'YOUR_TOKEN', // This must be give only to trusted clients to access protected endpoints directly
6
- 'CORS_ALLOWED_ORIGINS' => '*',
5
+ 'API_KEY' => 'DEFAULT_KEY', // Default key for protected endpoints that don't have a specific key in ENDPOINT_KEYS
7
6
 
7
+ // If you want restrict access to protected endpoints to specific clients, you can define custom keys for each endpoint
8
+ // For subfolder endpoints, use the relative path ('subfolder/endpoint')
9
+ 'ENDPOINT_KEYS' => [
10
+ 'subfolder/example-protected' => 'example-key',
11
+ ],
12
+
13
+ // Database configuration
8
14
  'DB_HOST' => '127.0.0.1',
9
15
  'DB_NAME' => 'example_db',
10
16
  'DB_USER' => 'root',
@@ -2,9 +2,15 @@
2
2
  declare(strict_types=1);
3
3
 
4
4
  return [
5
- 'API_KEY' => 'YOUR_TOKEN', // This must be give only to trusted clients to access protected endpoints directly
6
- 'CORS_ALLOWED_ORIGINS' => '*',
5
+ 'API_KEY' => 'DEFAULT_KEY', // Default key for protected endpoints that don't have a specific key in ENDPOINT_KEYS
7
6
 
7
+ // If you want restrict access to protected endpoints to specific clients, you can define custom keys for each endpoint
8
+ // For subfolder endpoints, use the relative path ('subfolder/endpoint')
9
+ 'ENDPOINT_KEYS' => [
10
+ 'subfolder/example-protected' => 'example-key',
11
+ ],
12
+
13
+ // Database configuration
8
14
  'DB_HOST' => '127.0.0.1',
9
15
  'DB_NAME' => 'example_db',
10
16
  'DB_USER' => 'root',
@@ -7,9 +7,6 @@ layout: base.njk
7
7
  {% if title == "homepage" %}
8
8
  {% include "welcome.njk" %}
9
9
 
10
- {% elif title == "examplePage" %}
11
- {#{% include "component.njk" %}#}
12
-
13
10
  {% else %}
14
11
  {% include "404/_404.njk" %}
15
12
  {{ content | safe }}
@@ -1,54 +1,44 @@
1
- {
2
- "site_name": "Site name",
3
- "title": "Site title",
4
- "description": "Site description",
5
- "keywords": "keyword1, keyword2, keyword3",
6
- "domain": "yoursite.com",
7
- "url": "https://yoursite.com",
8
- "lang": "en",
9
- "author": "Name and surname",
10
- "data_bs_theme": "dark",
11
- "favicon": "/assets/brand/favicon.svg",
12
- "logo": "/assets/brand/logo.svg",
13
- "copyright": {
14
- "year": "2026",
15
- "text": "Copyright text"
16
- },
17
- "legal": {
18
- "privacy": "",
19
- "cookie": "",
20
- "cookieControls": "",
21
- "terms": ""
22
- },
23
- "pages": {
24
- "404": {
25
- "seo": {
26
- "title": "404 - Not found"
27
- },
28
- "cdn": {
29
- "css": [],
30
- "js": []
31
- }
32
- },
33
- "homepage": {
34
- "seo": {
35
- "title": "Homepage",
36
- "description": "Description"
37
- },
38
- "cdn": {
39
- "css": [],
40
- "js": []
41
- }
42
- },
43
- "examplePage": {
44
- "seo": {
45
- "title": "Example Page",
46
- "description": "description"
47
- },
48
- "cdn": {
49
- "css": [],
50
- "js": []
51
- }
52
- }
53
- }
1
+ {
2
+ "site_name": "Site name",
3
+ "title": "Site title",
4
+ "description": "Site description",
5
+ "keywords": "keyword1, keyword2, keyword3",
6
+ "domain": "yoursite.com",
7
+ "url": "https://yoursite.com",
8
+ "lang": "en",
9
+ "author": "Name and surname",
10
+ "data_bs_theme": "dark",
11
+ "favicon": "/assets/brand/favicon.svg",
12
+ "logo": "/assets/brand/logo.svg",
13
+ "copyright": {
14
+ "year": "2026",
15
+ "text": "Copyright text"
16
+ },
17
+ "legal": {
18
+ "privacy": "",
19
+ "cookie": "",
20
+ "cookieControls": "",
21
+ "terms": ""
22
+ },
23
+ "pages": {
24
+ "404": {
25
+ "seo": {
26
+ "title": "404 - Not found"
27
+ },
28
+ "cdn": {
29
+ "css": [],
30
+ "js": []
31
+ }
32
+ },
33
+ "homepage": {
34
+ "seo": {
35
+ "title": "Homepage",
36
+ "description": "Description"
37
+ },
38
+ "cdn": {
39
+ "css": [],
40
+ "js": []
41
+ }
42
+ }
43
+ }
54
44
  }
@@ -3,10 +3,12 @@
3
3
  //==========================
4
4
 
5
5
  // Use @use with a namespace to avoid framework variable conflicts:
6
+ // Example: root.$primary
6
7
  @use "../modules/root" as root;
7
8
 
8
- // Page layout modules comment out any section you don't need
9
+ // This global module contains the import framework, necessary modules for each page and any other common styles
9
10
  @import "../modules/global";
11
+
10
12
  // Import any other module you need by import down here
11
13
  @import "../modules/notification";
12
14
 
@@ -3,10 +3,12 @@
3
3
  //==========================
4
4
 
5
5
  // Use @use with a namespace to avoid framework variable conflicts:
6
+ // Example: root.$primary
6
7
  @use "../modules/root" as root;
7
8
 
8
- // Page layout modules comment out any section you don't need
9
+ // This global module contains the import framework, necessary modules for each page and any other common styles
9
10
  @import "../modules/global";
11
+
10
12
  // Import any other module you need by import down here
11
13
  @import "../modules/notification";
12
14
 
@@ -1,9 +0,0 @@
1
- ---
2
- title: "examplePage"
3
- permalink: "/example-page/"
4
- layout: includes.njk
5
- ---
6
-
7
- <!-- !IMPORTANT -->
8
- <!-- DO NOT ADD ANYTHING HERE -->
9
- <!-- You should create a new component.njk into src/components and include that in components/layouts/includes.njk -->
@@ -1,19 +0,0 @@
1
- //==========================
2
- // JAVASCRIPT MODULES IMPORTS
3
- //==========================
4
-
5
- // Call anywhere
6
- import { showNotification } from '../modules/notification.js';
7
-
8
- // Uncomment to enable optional modules (call inside DOMContentLoaded)
9
- // import { initTextAreaAutoExpand } from '../modules/forms/textAreaAutoExpand.js';
10
- // import { initNormalizePhoneNumber } from '../modules/forms/normalizePhoneNumber.js';
11
-
12
- //==========================
13
- // PAGE CUSTOM JAVASCRIPT
14
- //==========================
15
-
16
- document.addEventListener("DOMContentLoaded", () => {
17
- });
18
-
19
- showNotification("Example notification", "success", 3000);
@@ -1,17 +0,0 @@
1
- //==========================
2
- // CSS MODULES IMPORTS
3
- //==========================
4
-
5
- @use "../modules/root" as root;
6
-
7
- @import "../modules/global";
8
- // Import any other module you need by import down here
9
- @import "../modules/notification";
10
-
11
- //==========================
12
- // PAGE CUSTOM CSS RULES
13
- //==========================
14
-
15
- // body {
16
- // background-color: root.$primary;
17
- // }