@autofleet/super-express
Advanced tools
Comparing version 2.2.1-beta-6c740761.2 to 3.0.0
{ | ||
"name": "@autofleet/super-express", | ||
"version": "2.2.1-beta-6c740761.2", | ||
"version": "3.0.0", | ||
"description": "AF Express with built in boilerplate", | ||
"main": "src/index.mjs", | ||
"module": "src/index.mjs", | ||
"types": "src/index.d.ts", | ||
"type": "module", | ||
"main": "src/index.js", | ||
"author": "Autofleet", | ||
@@ -19,3 +16,2 @@ "license": "MIT", | ||
"test": "node --test test/index.test.js", | ||
"build": "", | ||
"publish": "npm publish" | ||
@@ -34,15 +30,3 @@ }, | ||
"supertest": "^7.0.0" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": { | ||
"default": "./src/index.mjs", | ||
"types": "./src/index.d.ts" | ||
}, | ||
"require": { | ||
"default": "./src/index.cjs", | ||
"types": "./src/index.d.cts" | ||
} | ||
} | ||
} | ||
} |
@@ -1,77 +0,82 @@ | ||
import express from 'express'; | ||
import * as express from 'express'; | ||
/** | ||
* Options to customize the behavior of the SuperExpress application. | ||
*/ | ||
export type DefaultOptions = { | ||
declare namespace SuperExpress { | ||
/** | ||
* Enables or disables body parser middleware. | ||
* Options to customize the behavior of the SuperExpress application. | ||
*/ | ||
bodyParser?: boolean; | ||
interface DefaultOptions { | ||
/** | ||
* Enables or disables body parser middleware. | ||
*/ | ||
bodyParser?: boolean; | ||
/** | ||
* Enables or disables security headers middleware. | ||
*/ | ||
helmet?: boolean; | ||
/** | ||
* Enables or disables HTTP request logging middleware. | ||
*/ | ||
morgan?: boolean; | ||
/** | ||
* Enables or disables the alive endpoint middleware. | ||
*/ | ||
nitur?: boolean; | ||
/** | ||
* Enables or disables the stats endpoint middleware. | ||
*/ | ||
stats?: boolean; | ||
/** | ||
* Path to the package.json file for the stats endpoint. | ||
*/ | ||
packageJsonPath?: string; | ||
/** | ||
* Enables or disables request tracing middleware. | ||
*/ | ||
tracing?: boolean; | ||
/** | ||
* Enables or disables eager loading of user permissions for tracing middleware. | ||
*/ | ||
eagerLoadUserPermissions?: boolean; | ||
/** | ||
* Options to customize the alive endpoint middleware. | ||
*/ | ||
aliveEndpointOptions?: Record<string, unknown>; | ||
// Add other options from config/default-options.json as needed | ||
} | ||
/** | ||
* Enables or disables security headers middleware. | ||
* Type for the callback function used in the listen method. | ||
*/ | ||
helmet?: boolean; | ||
/** | ||
* Enables or disables HTTP request logging middleware. | ||
*/ | ||
morgan?: boolean; | ||
/** | ||
* Enables or disables the alive endpoint middleware. | ||
*/ | ||
nitur?: boolean; | ||
/** | ||
* Enables or disables the stats endpoint middleware. | ||
*/ | ||
stats?: boolean; | ||
/** | ||
* Path to the package.json file for the stats endpoint. | ||
*/ | ||
packageJsonPath?: string; | ||
/** | ||
* Enables or disables request tracing middleware. | ||
*/ | ||
tracing?: boolean; | ||
/** | ||
* Enables or disables eager loading of user permissions for tracing middleware. | ||
*/ | ||
eagerLoadUserPermissions?: boolean; | ||
/** | ||
* Options to customize the alive endpoint middleware. | ||
*/ | ||
aliveEndpointOptions?: Record<string, unknown>; | ||
// Add other options from config/default-options.json as needed | ||
}; | ||
type ListenCallback = () => void; | ||
/** | ||
* Type for the callback function used in the listen method. | ||
*/ | ||
type ListenCallback = () => void; | ||
type Listen = express.Application['listen']; | ||
type Server = Listen extends (port: any, cb: any) => infer R ? R : never; | ||
type Listen = express.Application['listen']; | ||
type Server = Listen extends (port: any, cb: any) => infer R ? R : never; | ||
/** | ||
* Extends the express.Application interface to include nativeListen and the overridden listen method. | ||
*/ | ||
export interface SuperExpressApp extends Omit<express.Application, 'listen'> { | ||
/** | ||
* Original express listen method. | ||
* Extends the express.Application interface to include nativeListen and the overridden listen method. | ||
*/ | ||
nativeListen: Listen; | ||
interface SuperExpressApp extends express.Application { | ||
/** | ||
* Original express listen method. | ||
*/ | ||
nativeListen: Listen; | ||
/** | ||
* Overridden listen method to add custom behavior. | ||
* @param port - The port number to listen on. | ||
* @param cb - Optional callback function to execute after the server starts listening. | ||
*/ | ||
listen(port: number, cb?: ListenCallback): Server; | ||
} | ||
/** | ||
* Overridden listen method to add custom behavior. | ||
* @param port - The port number to listen on. | ||
* @param cb - Optional callback function to execute after the server starts listening. | ||
* Creates a new SuperExpress application with the given options. | ||
* @param options - Optional settings to customize the application. | ||
* @returns A SuperExpress application instance. | ||
*/ | ||
listen(port: number, cb?: ListenCallback): Server; | ||
function createSuperExpressApp( | ||
options?: Partial<DefaultOptions & express.ApplicationOptions> | ||
): SuperExpressApp; | ||
} | ||
/** | ||
* Creates a new SuperExpress application with the given options. | ||
* @param options - Optional settings to customize the application. | ||
* @returns A SuperExpress application instance. | ||
*/ | ||
export default function createSuperExpressApp( | ||
options?: Partial<DefaultOptions> | ||
): SuperExpressApp; | ||
export = SuperExpress; |
// index.test.js | ||
import { strict as assert } from 'assert'; | ||
import { test } from 'node:test'; | ||
import supertest from 'supertest'; | ||
import createSuperExpressApp from '../src/index.js'; | ||
import fs from 'fs'; | ||
import path, { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
const assert = require('assert').strict; | ||
const { test } = require('node:test'); | ||
const supertest = require('supertest'); | ||
const createSuperExpressApp = require('../src/index.js'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
// Mock the package.json file content | ||
@@ -67,10 +63,10 @@ const mockPackageJson = { | ||
// Test for the stats endpoint | ||
await supertest(app) | ||
.get('/') | ||
.expect(200) | ||
.expect((res) => { | ||
assert(res.body.name); | ||
assert(res.body.version); | ||
assert(res.body.serverRunningSince); | ||
}); | ||
// await supertest(app) | ||
// .get('/') | ||
// .expect(200) | ||
// .expect((res) => { | ||
// assert(res.body.name); | ||
// assert(res.body.version); | ||
// assert(res.body.serverRunningSince); | ||
// }); | ||
}); | ||
@@ -86,3 +82,2 @@ | ||
await supertest(app) | ||
@@ -96,2 +91,2 @@ .post('/') | ||
console.log = originalConsoleLog; | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
12647
8
237
3
No