create-berna-stencil 1.0.19 → 1.0.20
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 +1 -2
- package/.gitignore +0 -1
- package/bin/create.js +1 -2
- package/package.json +71 -72
- package/src/api/.htaccess +7 -8
- package/src/api/config.php +21 -0
- package/src/api/core/init.php +15 -17
- package/src/api/core/modules/Response.php +12 -0
- package/src/api/index.php +2 -2
- package/.env.example +0 -8
- package/src/api/core/.htaccess +0 -2
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 = "out";
|
|
7
|
+
const OUTPUT_DIR = "c:/laragon/www/Berna-Stencil-out";
|
|
8
8
|
|
|
9
9
|
module.exports = function (eleventyConfig) {
|
|
10
10
|
|
|
@@ -24,7 +24,6 @@ module.exports = function (eleventyConfig) {
|
|
|
24
24
|
// =====================================================
|
|
25
25
|
// PASSTHROUGH — Static files
|
|
26
26
|
// =====================================================
|
|
27
|
-
eleventyConfig.addPassthroughCopy(".env");
|
|
28
27
|
eleventyConfig.addPassthroughCopy("src/.htaccess");
|
|
29
28
|
eleventyConfig.addPassthroughCopy("src/api");
|
|
30
29
|
eleventyConfig.addPassthroughCopy("src/assets");
|
package/.gitignore
CHANGED
package/bin/create.js
CHANGED
|
@@ -12,13 +12,12 @@ const COPY_TARGETS = [
|
|
|
12
12
|
'.eleventy.js',
|
|
13
13
|
'.eleventyignore',
|
|
14
14
|
'.gitignore',
|
|
15
|
-
".env.example",
|
|
16
15
|
'README.md',
|
|
17
16
|
];
|
|
18
17
|
|
|
19
18
|
const PROJECT_PACKAGE = {
|
|
20
19
|
name: path.basename(targetDir),
|
|
21
|
-
version: '1.0.
|
|
20
|
+
version: '1.0.20',
|
|
22
21
|
private: true,
|
|
23
22
|
scripts: {
|
|
24
23
|
'build:css': 'sass src/scss:out/css --no-source-map --style=compressed --quiet',
|
package/package.json
CHANGED
|
@@ -1,73 +1,72 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "create-berna-stencil",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Eleventy boilerplate with per-page SCSS/JS pipeline, esbuild bundling, multi-framework CSS support and a built-in page management CLI",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"eleventy",
|
|
7
|
-
"11ty",
|
|
8
|
-
"boilerplate",
|
|
9
|
-
"starter",
|
|
10
|
-
"scss",
|
|
11
|
-
"esbuild",
|
|
12
|
-
"bootstrap",
|
|
13
|
-
"bulma",
|
|
14
|
-
"foundation",
|
|
15
|
-
"uikit",
|
|
16
|
-
"static-site",
|
|
17
|
-
"nunjucks"
|
|
18
|
-
],
|
|
19
|
-
"author": "Michele Garofalo",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "https://github.com/rhaastrake/berna-stencil"
|
|
24
|
-
},
|
|
25
|
-
"homepage": "https://github.com/rhaastrake/berna-stencil#readme",
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/rhaastrake/berna-stencil/issues"
|
|
28
|
-
},
|
|
29
|
-
"bin": {
|
|
30
|
-
"create-berna-stencil": "bin/create.js"
|
|
31
|
-
},
|
|
32
|
-
"files": [
|
|
33
|
-
"bin/",
|
|
34
|
-
"src/",
|
|
35
|
-
"_tools/",
|
|
36
|
-
".eleventy.js",
|
|
37
|
-
".eleventyignore",
|
|
38
|
-
".gitignore",
|
|
39
|
-
".
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"@11ty/eleventy": "^
|
|
47
|
-
"
|
|
48
|
-
"bootstrap": "^
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"build:
|
|
62
|
-
"build:
|
|
63
|
-
"build:
|
|
64
|
-
"
|
|
65
|
-
"serve:
|
|
66
|
-
"serve:
|
|
67
|
-
"
|
|
68
|
-
"clean": "
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "create-berna-stencil",
|
|
3
|
+
"version": "1.0.20",
|
|
4
|
+
"description": "Eleventy boilerplate with per-page SCSS/JS pipeline, esbuild bundling, multi-framework CSS support and a built-in page management CLI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eleventy",
|
|
7
|
+
"11ty",
|
|
8
|
+
"boilerplate",
|
|
9
|
+
"starter",
|
|
10
|
+
"scss",
|
|
11
|
+
"esbuild",
|
|
12
|
+
"bootstrap",
|
|
13
|
+
"bulma",
|
|
14
|
+
"foundation",
|
|
15
|
+
"uikit",
|
|
16
|
+
"static-site",
|
|
17
|
+
"nunjucks"
|
|
18
|
+
],
|
|
19
|
+
"author": "Michele Garofalo",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/rhaastrake/berna-stencil"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/rhaastrake/berna-stencil#readme",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/rhaastrake/berna-stencil/issues"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"create-berna-stencil": "bin/create.js"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"bin/",
|
|
34
|
+
"src/",
|
|
35
|
+
"_tools/",
|
|
36
|
+
".eleventy.js",
|
|
37
|
+
".eleventyignore",
|
|
38
|
+
".gitignore",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@11ty/eleventy": "^3.1.2",
|
|
46
|
+
"@11ty/eleventy-img": "^6.0.4",
|
|
47
|
+
"bootstrap": "^5.3.8",
|
|
48
|
+
"bootstrap-icons": "^1.13.1",
|
|
49
|
+
"bulma": "^1.0.4",
|
|
50
|
+
"foundation-sites": "^6.9.0",
|
|
51
|
+
"glob": "^13.0.6",
|
|
52
|
+
"uikit": "^3.25.13"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"concurrently": "^9.2.1",
|
|
56
|
+
"esbuild": "^0.27.3",
|
|
57
|
+
"sass": "^1.77.0"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build:css": "sass src/scss:c:/laragon/www/Berna-Stencil-out/css --no-source-map --style=compressed --quiet",
|
|
61
|
+
"build:js": "esbuild \"src/js/pages/*.js\" --bundle --outdir=c:/laragon/www/Berna-Stencil-out/js/pages --minify",
|
|
62
|
+
"build:11ty": "eleventy",
|
|
63
|
+
"build": "npm run build:css && npm run build:js && npm run build:11ty",
|
|
64
|
+
"serve:css": "sass --watch src/scss:c:/laragon/www/Berna-Stencil-out/css --no-source-map --quiet",
|
|
65
|
+
"serve:js": "esbuild \"src/js/pages/*.js\" --bundle --outdir=c:/laragon/www/Berna-Stencil-out/js/pages --watch",
|
|
66
|
+
"serve:11ty": "eleventy --serve --quiet",
|
|
67
|
+
"clean": "node _tools/cleanOutput.js",
|
|
68
|
+
"serve": "npm run clean && concurrently \"npm run serve:11ty\" \"npm run serve:css\" \"npm run serve:js\"",
|
|
69
|
+
"assistant": "node _tools/assistant.js",
|
|
70
|
+
"postinstall": "cd src/api/core && composer install"
|
|
71
|
+
}
|
|
73
72
|
}
|
package/src/api/.htaccess
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
RewriteEngine On
|
|
3
3
|
RewriteBase /api/
|
|
4
4
|
|
|
5
|
-
# 1.
|
|
6
|
-
|
|
7
|
-
Require all denied
|
|
8
|
-
</FilesMatch>
|
|
5
|
+
# 1. Permetti index.php
|
|
6
|
+
RewriteRule ^index\.php$ - [L]
|
|
9
7
|
|
|
10
|
-
# 2.
|
|
11
|
-
#
|
|
12
|
-
RewriteRule
|
|
8
|
+
# 2. Invece di dare Forbidden [F], manda tutto a index.php
|
|
9
|
+
# Questo copre config.php e tutte le sottocartelle
|
|
10
|
+
RewriteRule \.php$ index.php [L]
|
|
11
|
+
RewriteRule ^(core|endpoints|modules|vendor)($|/) index.php [L]
|
|
13
12
|
|
|
14
|
-
# 3. Regola
|
|
13
|
+
# 3. Regola per gli endpoint
|
|
15
14
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
16
15
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|
17
16
|
RewriteRule ^(.*)$ index.php [QSA,L]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
declare(strict_types=1);
|
|
3
|
+
|
|
4
|
+
// Impedisce l'accesso diretto via URL
|
|
5
|
+
if (!defined('CORE_ACCESS')) {
|
|
6
|
+
http_response_code(403);
|
|
7
|
+
die('Accesso diretto non consentito.');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return [
|
|
11
|
+
// Configurazioni di base
|
|
12
|
+
'API_KEY' => 'TOKEN',
|
|
13
|
+
'CORS_ALLOWED_ORIGINS' => '*',
|
|
14
|
+
|
|
15
|
+
// Configurazioni per l'invio delle Email
|
|
16
|
+
'MAIL_HOST' => 'smtp.gmail.com',
|
|
17
|
+
'MAIL_PORT' => 587, // Per i numeri puoi omettere gli apici
|
|
18
|
+
'MAIL_USERNAME' => 'YOUR_EMAIL',
|
|
19
|
+
'MAIL_PASSWORD' => 'APP_PASSWORD',
|
|
20
|
+
'MAIL_TO_ADDRESS' => 'EMAIL_TO_ADDRESS',
|
|
21
|
+
];
|
package/src/api/core/init.php
CHANGED
|
@@ -2,16 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
declare(strict_types=1);
|
|
4
4
|
|
|
5
|
+
// Impedisce l'accesso diretto a questo file
|
|
5
6
|
if (!defined('CORE_ACCESS')) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
$errorPage = $_SERVER['DOCUMENT_ROOT'] . '/404.html';
|
|
8
|
+
http_response_code(404);
|
|
9
|
+
if (file_exists($errorPage)) {
|
|
10
|
+
header('Content-Type: text/html; charset=UTF-8');
|
|
11
|
+
echo file_get_contents($errorPage);
|
|
12
|
+
} else {
|
|
13
|
+
echo "404 Not Found";
|
|
14
|
+
}
|
|
15
|
+
exit;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
11
19
|
require_once __DIR__ . '/modules/Response.php';
|
|
12
20
|
|
|
13
21
|
// --- GESTORE GLOBALE ERRORI E ECCEZIONI ---
|
|
14
|
-
// Trasforma ogni errore PHP in una risposta JSON pulita
|
|
15
22
|
set_exception_handler(function ($exception) {
|
|
16
23
|
Response::error(
|
|
17
24
|
$exception->getMessage(),
|
|
@@ -25,21 +32,12 @@ set_error_handler(function ($severity, $message, $file, $line) {
|
|
|
25
32
|
throw new ErrorException($message, 0, $severity, $file, $line);
|
|
26
33
|
});
|
|
27
34
|
|
|
28
|
-
// --- CARICAMENTO
|
|
29
|
-
// dirname(__DIR__
|
|
30
|
-
|
|
31
|
-
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__, 2));
|
|
32
|
-
$dotenv->load();
|
|
33
|
-
} catch (Exception $e) {
|
|
34
|
-
Response::error("Impossibile caricare il file .env. Assicurati che esista nella root e si chiami esattamente .env", 500);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
$dotenv->required([
|
|
38
|
-
'API_KEY',
|
|
39
|
-
'CORS_ALLOWED_ORIGINS',
|
|
40
|
-
]);
|
|
35
|
+
// --- CARICAMENTO CONFIGURAZIONE ---
|
|
36
|
+
// dirname(__DIR__) punta alla cartella /api/ dove ora si trova config.php
|
|
37
|
+
$config = require dirname(__DIR__) . '/config.php';
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
// --- CONFIGURAZIONE AMBIENTE ---
|
|
40
|
+
if (($config['APP_ENV'] ?? 'production') === 'production') {
|
|
43
41
|
ini_set('display_errors', '0');
|
|
44
42
|
error_reporting(0);
|
|
45
43
|
} else {
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
declare(strict_types=1);
|
|
4
4
|
|
|
5
|
+
if (!defined('CORE_ACCESS')) {
|
|
6
|
+
$errorPage = $_SERVER['DOCUMENT_ROOT'] . '/404.html';
|
|
7
|
+
http_response_code(404);
|
|
8
|
+
if (file_exists($errorPage)) {
|
|
9
|
+
header('Content-Type: text/html; charset=UTF-8');
|
|
10
|
+
echo file_get_contents($errorPage);
|
|
11
|
+
} else {
|
|
12
|
+
echo "404 Not Found";
|
|
13
|
+
}
|
|
14
|
+
exit;
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
class Response
|
|
6
18
|
{
|
|
7
19
|
public static function success(mixed $data = null, int $code = 200): never
|
package/src/api/index.php
CHANGED
|
@@ -60,7 +60,7 @@ header('Content-Type: application/json; charset=UTF-8');
|
|
|
60
60
|
header('Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS');
|
|
61
61
|
header('Access-Control-Allow-Headers: Content-Type, X-Api-Key');
|
|
62
62
|
|
|
63
|
-
$allowedOrigins = array_filter(array_map('trim', explode(',', $
|
|
63
|
+
$allowedOrigins = array_filter(array_map('trim', explode(',', $config['CORS_ALLOWED_ORIGINS'] ?? '')));
|
|
64
64
|
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
|
65
65
|
|
|
66
66
|
if (in_array($origin, $allowedOrigins, true) || in_array('*', $allowedOrigins, true)) {
|
|
@@ -80,7 +80,7 @@ if ($method === 'OPTIONS') {
|
|
|
80
80
|
|
|
81
81
|
if ($isProtected) {
|
|
82
82
|
$apiKey = $_SERVER['HTTP_X_API_KEY'] ?? '';
|
|
83
|
-
$validKey = $
|
|
83
|
+
$validKey = $config['API_KEY'] ?? '';
|
|
84
84
|
|
|
85
85
|
if ($validKey === '' || $apiKey !== $validKey) {
|
|
86
86
|
Response::error('Unauthorized', 401);
|
package/.env.example
DELETED
package/src/api/core/.htaccess
DELETED