@cored3v/web-core 1.0.3 → 1.0.4

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/README.md CHANGED
@@ -7,11 +7,13 @@ It supports **Express.js**, **Next.js**, **Nuxt (H3)**, and generic Node.js envi
7
7
  ## Features
8
8
 
9
9
  - **License Enforcement**: Protect your source code by enforcing valid license keys.
10
- - **JWT Authentication**: Built-in JWT verification helper and middleware.
11
- - **Database Management**: Automatic Postgres connection pooling and lifecycle management.
10
+ - **JWT Authentication**: Optional, built-in JWT verification helper and middleware.
11
+ - **Database Management**: Optional, automatic Postgres connection pooling and lifecycle management.
12
12
  - **Security Defaults**: Pre-configured Helmet and CORS for Express.
13
13
  - **Multi-Framework**: First-class adapters for Express, Next.js, and H3.
14
14
 
15
+ > **Note**: Only **License Enforcement** and **Routes** are mandatory. Auth and Database modules are opt-in and handled via configuration.
16
+
15
17
  ## Installation
16
18
 
17
19
  ```bash
@@ -98,10 +100,13 @@ The library uses `dotenv` to load configuration. Ensure you have a `.env` file o
98
100
  | Variable | Description | Required | Default |
99
101
  |----------|-------------|----------|---------|
100
102
  | `LICENSE_PATH` | Path to the `license.json` file | No | `./license.json` |
101
- | `JWT_SECRET` | Secret key for JWT verification | **Yes** | - |
103
+ | `JWT_SECRET` | Secret key for JWT verification | **Yes** (if auth used) | - |
102
104
  | `DATABASE_URL` | Postgres Connection String | No | - |
103
105
  | `PORT` | Http Port (Express only) | No | `3000` |
104
106
 
107
+ **Note:**
108
+ `license.json` is mandatory for the app to work. However, if the file exists in root directory, then LICENSE_PATH env variable is not required.
109
+
105
110
  ## License
106
111
 
107
112
  Private / Proprietary.
@@ -65,7 +65,10 @@ async function createApp(opts) {
65
65
  // 5) DB (non-optional if declared)
66
66
  const db = await (0, index_js_2.initDb)(opts.db);
67
67
  // 6) AUTH
68
- const auth = (0, jwt_js_1.initJwtAuth)(config);
68
+ let auth;
69
+ if (opts.auth) {
70
+ auth = (0, jwt_js_1.initJwtAuth)(config);
71
+ }
69
72
  // 7) ROUTES
70
73
  if (opts.routes) {
71
74
  opts.routes({ app, router, db, auth, config });
@@ -7,13 +7,13 @@ exports.verifySignature = verifySignature;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
8
  const PUBLIC_KEY = `
9
9
  -----BEGIN PUBLIC KEY-----
10
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsU0BSgfcYaHOuWuNRQEw
11
- t3HyMf+UY+RAVGf0bDmdXIyp5fPol5K86jol45lIaxdbkMpPqODmr/lU0dDBOIwy
12
- wlhbAQb0nLsIMQf3M6lNw6OtI0EnlZd2xhfisfu1XH9UBbn7Q6W2+i22rZhKC3yY
13
- 8E7Dntgl7IkItjEFFpnbA4tCY6yTGhGfAx/4O977Vw2ET6m5SVcFVlKs0OxekRc0
14
- 7rcgCTwSjHPkMumVc7zv+rfZPkhULN76ju26gcuR19xd+gNq3qLGgJ9hcDITmuwP
15
- FE212I94elpNRNbrX7MUqVX3o7trE5CqxH42NuGP20edSWcKqpvqLFPSnlsSvhUp
16
- MQIDAQAB
10
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCxkEU67ODBGA9LQbMrm
11
+ mquTktu9xme2nJKPoPce1cYqjTOt/NJ2a+LDuhM7t8PHVye18+RJq+mFOkOSgilo
12
+ qpsoM/45NqN4doBkfajZqXtCSjiYg2F4O/zppElzTlsFxc7vtKs+KoTE91s0w0e6
13
+ xTrgdpqwZnUQ9q+16tuCIKPdxJ4mwqZbnUXdE3WKfedbnI2DNE0CfpJFrLkpSsnK
14
+ s/gcPBCi4obvE2RJWNqWoMULW6iLXSNqwDmxE+o87hwCTGfpZ/bxyirRbBCSq/hY
15
+ SdVQJlDhE2ta6CoITROp0c3+xffpCvlYnADp544nuz5IlTZk7LN9X5mF27VcTPc6
16
+ bwIDAQAB
17
17
  -----END PUBLIC KEY-----
18
18
  `;
19
19
  function verifySignature(payload, signature) {
@@ -17,8 +17,8 @@ export interface CreateAppOptions {
17
17
  export interface AppContext {
18
18
  app: Express;
19
19
  router: Router;
20
- db: any;
21
- auth: {
20
+ db?: any;
21
+ auth?: {
22
22
  middleware(): any;
23
23
  };
24
24
  config: Config;
@@ -26,7 +26,10 @@ export async function createApp(opts) {
26
26
  // 5) DB (non-optional if declared)
27
27
  const db = await initDb(opts.db);
28
28
  // 6) AUTH
29
- const auth = initJwtAuth(config);
29
+ let auth;
30
+ if (opts.auth) {
31
+ auth = initJwtAuth(config);
32
+ }
30
33
  // 7) ROUTES
31
34
  if (opts.routes) {
32
35
  opts.routes({ app, router, db, auth, config });
@@ -1,13 +1,13 @@
1
1
  import crypto from "crypto";
2
2
  const PUBLIC_KEY = `
3
3
  -----BEGIN PUBLIC KEY-----
4
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsU0BSgfcYaHOuWuNRQEw
5
- t3HyMf+UY+RAVGf0bDmdXIyp5fPol5K86jol45lIaxdbkMpPqODmr/lU0dDBOIwy
6
- wlhbAQb0nLsIMQf3M6lNw6OtI0EnlZd2xhfisfu1XH9UBbn7Q6W2+i22rZhKC3yY
7
- 8E7Dntgl7IkItjEFFpnbA4tCY6yTGhGfAx/4O977Vw2ET6m5SVcFVlKs0OxekRc0
8
- 7rcgCTwSjHPkMumVc7zv+rfZPkhULN76ju26gcuR19xd+gNq3qLGgJ9hcDITmuwP
9
- FE212I94elpNRNbrX7MUqVX3o7trE5CqxH42NuGP20edSWcKqpvqLFPSnlsSvhUp
10
- MQIDAQAB
4
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCxkEU67ODBGA9LQbMrm
5
+ mquTktu9xme2nJKPoPce1cYqjTOt/NJ2a+LDuhM7t8PHVye18+RJq+mFOkOSgilo
6
+ qpsoM/45NqN4doBkfajZqXtCSjiYg2F4O/zppElzTlsFxc7vtKs+KoTE91s0w0e6
7
+ xTrgdpqwZnUQ9q+16tuCIKPdxJ4mwqZbnUXdE3WKfedbnI2DNE0CfpJFrLkpSsnK
8
+ s/gcPBCi4obvE2RJWNqWoMULW6iLXSNqwDmxE+o87hwCTGfpZ/bxyirRbBCSq/hY
9
+ SdVQJlDhE2ta6CoITROp0c3+xffpCvlYnADp544nuz5IlTZk7LN9X5mF27VcTPc6
10
+ bwIDAQAB
11
11
  -----END PUBLIC KEY-----
12
12
  `;
13
13
  export function verifySignature(payload, signature) {
@@ -17,8 +17,8 @@ export interface CreateAppOptions {
17
17
  export interface AppContext {
18
18
  app: Express;
19
19
  router: Router;
20
- db: any;
21
- auth: {
20
+ db?: any;
21
+ auth?: {
22
22
  middleware(): any;
23
23
  };
24
24
  config: Config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cored3v/web-core",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Reusable licensed Express core for web applications",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.cjs",