Skip to content

Commit

Permalink
feat: add certificates generate
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamensuli committed Feb 1, 2024
1 parent 5dbcf5c commit 5fa4b64
Show file tree
Hide file tree
Showing 24 changed files with 2,417 additions and 357 deletions.
50 changes: 14 additions & 36 deletions nodefony/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@
import path from "node:path";
import { Nodefony } from "nodefony";
const kernel = Nodefony.kernel;
import http from "./module-http-config";

const certificats = {
options: {
rejectUnauthorized: true,
},
key: "",
cert: "",
ca: "",
};
let CDN = null;
let statics = true;
let monitoring = true;
Expand All @@ -43,27 +36,6 @@ switch (kernel?.environment) {
case "production":
case "development":
default:
certificats.key = path.resolve(
"nodefony",
"config",
"certificates",
"server",
"privkey.pem"
);
certificats.cert = path.resolve(
"nodefony",
"config",
"certificates",
"server",
"fullchain.pem"
);
certificats.ca = path.resolve(
"nodefony",
"config",
"certificates",
"ca",
"nodefony-root-ca.crt.pem"
);
CDN = null;
statics = true;
documentation = true;
Expand All @@ -76,11 +48,17 @@ export default {
domain: "localhost", // "0.0.0.0" "selectAuto"
domainAlias: ["^127.0.0.1$", "^localhost$"],
domainCheck,
locale: "en_en",
App: {
projectYear: "2024",
locale: "en_en",
authorName: "Camensuli Christophe",
authorMail: "[email protected]",
},
servers: {
statics,
http: {
port: 5151,
protocol: "2.0", // 2.0 || 1.1
},
https: {
port: 5152,
Expand All @@ -89,18 +67,13 @@ export default {
ws: {},
wss: {},
},
certificats,
// httpPort: 5151,
// httpsPort: 5152,

locale: "en_en",

/**
* SERVERS
*/
// servers: {
// statics,
// protocol: "2.0", // 2.0 || 1.1
// protocol: "2.0",
// http: true,
// https: true,
// ws: true,
Expand Down Expand Up @@ -179,4 +152,9 @@ export default {
* pnpm
*/
packageManager: "yarn",

/*
* OVERRIDE modules config
*/
"module-http": http,
};
52 changes: 52 additions & 0 deletions nodefony/config/module-http-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Nodefony } from "nodefony";
const kernel = Nodefony.kernel;
import path from "node:path";

const certificates = {
path: path.resolve(kernel?.path || ".", "nodefony", "config", "certificates"),
privateKeyPath: "",
certPath: "",
caPath: "",
key: "",
cert: "",
ca: "",
openssl: {
size: 2048,
attrs: [
{ name: "commonName", value: `${kernel?.domain}` || "nodefony.com" },
{ name: "organizationName", value: kernel?.projectName || "" },
{ name: "organizationalUnitName", value: "Development" },
{ name: "countryName", value: "FR" },
{ name: "stateOrProvinceName", value: "BDR" },
{ name: "localityName", value: "Marseille" },
{ name: "organizationName", value: "Nodefony Signing Authority" },
//{ name: "emailAddress", value: `admin@${kernel?.domain}` },
],
},
};

switch (kernel?.environment) {
case "production":
case "development":
default:
certificates.privateKeyPath = path.resolve(
certificates.path,
"server",
"privkey.pem"
);
certificates.certPath = path.resolve(
certificates.path,
"server",
"cert.pem"
);
certificates.caPath = path.resolve(
certificates.path,
"ca",
"nodefony-root-ca.crt.pem"
);
}

export default {
rejectUnauthorized: true,
certificates,
};
Loading

0 comments on commit 5fa4b64

Please sign in to comment.