Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@autofleet/super-express

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@autofleet/super-express - npm Package Compare versions

Comparing version 2.2.1-beta-6c740761.2 to 3.0.0

src/index.js

20

package.json
{
"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;
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc