Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,240 changes: 566 additions & 674 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,38 @@
"re2": "^1.17.7"
},
"devDependencies": {
"@eslint/js": "^9.35.0",
"@eslint/js": "^10.0.1",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
"@types/connect": "^3.4.35",
"@types/mime-types": "^2.1.1",
"@types/mocha": "^10.0.0",
"@types/node": "^24.3.1",
"@types/node": "^26.1.1",
"@types/supertest": "^6.0.2",
"chai": "^4.4.1",
"chai-as-promised": "^7.1.2",
"concat-stream": "^2.0.0",
"eslint": "^9.35.0",
"eslint": "^10.6.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jsdoc": "^60.6.0",
"eslint-plugin-prettier": "^5.5.4",
"globals": "^16.3.0",
"eslint-plugin-jsdoc": "^63.0.12",
"eslint-plugin-prettier": "^5.5.6",
"globals": "^17.7.0",
"mocha": "^11.7.2",
"nyc": "^18.0.0",
"prettier": "^3.1.1",
"prettier": "^3.9.4",
"rimraf": "^6.0.1",
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0",
"source-map-support": "^0.5.21",
"std-mocks": "^2.0.0",
"supertest": "^7.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.9.2",
"typescript-eslint": "^8.43.0"
"typescript": "^6.0.3",
"typescript-eslint": "^8.63.0"
},
"overrides": {
"diff": "8.0.4",
"serialize-javascript": "7.0.7"
}
}
6 changes: 2 additions & 4 deletions src/middleware/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ export function env(spec: { env: Record<string, string> }) {
next: () => void,
): void => {
// const config = req.superstatic.env;
let env = undefined;
if (spec.env || req.superstatic.env) {
env = Object.assign({}, req.superstatic.env, spec.env);
} else {
if (!spec.env && !req.superstatic.env) {
return next();
}
const env = Object.assign({}, req.superstatic.env, spec.env);

if (req.url === "/__/env.json") {
res.superstatic.handleData({
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/rewrites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function matcher(rewrites: Rewrite[]) {
* Looks for possible rewrites for the given req.url.
* @returns middleware for handling rewrites.
*/
module.exports = function () {
export = function () {
return function (
req: IncomingMessage & { superstatic: Configuration },
res: ServerResponse & { superstatic: Responder },
Expand Down
4 changes: 1 addition & 3 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ module.exports = function (spec) {
// Override method because port and host are given
// in the spec object
app.listen = function (done) {
let server = {};

app.use(superstatic(spec));

// Start server
server = listen(spec.port, spec.hostname ?? spec.host, done);
const server = listen(spec.port, spec.hostname ?? spec.host, done);

return server;
};
Expand Down
4 changes: 2 additions & 2 deletions test/integration/clean-urls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/

import * as fs from "node:fs/promises";
import * as connect from "connect";
import * as request from "supertest";
import connect from "connect";
import request from "supertest";

import superstatic from "../../src/";
import { MiddlewareOptions } from "../../src/options";
Expand Down
4 changes: 2 additions & 2 deletions test/integration/error-pages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/

import * as fs from "node:fs/promises";
import * as connect from "connect";
import * as request from "supertest";
import connect from "connect";
import request from "supertest";

import superstatic from "../../src/";
import { MiddlewareOptions } from "../../src/options";
Expand Down
4 changes: 2 additions & 2 deletions test/integration/i18n.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/

import * as fs from "node:fs/promises";
import * as connect from "connect";
import * as request from "supertest";
import connect from "connect";
import request from "supertest";

import superstatic from "../../src/";
import { MiddlewareOptions } from "../../src/options";
Expand Down
4 changes: 2 additions & 2 deletions test/integration/serving-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import * as fs from "node:fs/promises";
import { join } from "path";
import * as connect from "connect";
import * as request from "supertest";
import connect from "connect";
import request from "supertest";

import superstatic from "../../src/";
import { MiddlewareOptions } from "../../src/options";
Expand Down
8 changes: 4 additions & 4 deletions test/unit/middleware/files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

import * as fs from "node:fs/promises";
import { expect } from "chai";
import * as request from "supertest";
import * as connect from "connect";
import request from "supertest";
import connect from "connect";
import { ServerResponse } from "node:http";

import * as helpers from "../../helpers";
import * as filesPkg from "../../../src/middleware/files";
import filesPkg from "../../../src/middleware/files";
const fsProvider = require("../../../src/providers/fs");
import * as Responder from "../../../src/responder";
import Responder from "../../../src/responder";

const files = helpers.decorator(filesPkg);

Expand Down
8 changes: 4 additions & 4 deletions test/unit/middleware/missing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import * as connect from "connect";
import connect from "connect";
import * as fs from "node:fs/promises";
import * as request from "supertest";
import request from "supertest";

const fsProvider = require("../../../src/providers/fs");
import * as helpers from "../../helpers";
import * as missingModule from "../../../src/middleware/missing";
import * as Responder from "../../../src/responder";
import missingModule from "../../../src/middleware/missing";
import Responder from "../../../src/responder";

const missing = helpers.decorator(missingModule);

Expand Down
8 changes: 4 additions & 4 deletions test/unit/middleware/rewrites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
*/

import * as fs from "node:fs/promises";
import * as request from "supertest";
import * as connect from "connect";
import request from "supertest";
import connect from "connect";

import * as helpers from "../../helpers";
import * as rewritesPkg from "../../../src/middleware/rewrites";
import rewritesPkg from "../../../src/middleware/rewrites";
const fsProvider = require("../../../src/providers/fs");
import * as Responder from "../../../src/responder";
import Responder from "../../../src/responder";

const rewrites = helpers.decorator(rewritesPkg);

Expand Down
2 changes: 1 addition & 1 deletion test/unit/providers/fs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

import { use, expect } from "chai";
import * as chaiAsPromised from "chai-as-promised";
import chaiAsPromised from "chai-as-promised";
import * as path from "node:path";
import * as fs from "node:fs";
const concatStream = require("concat-stream");
Expand Down
6 changes: 6 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"declaration": true,
"module": "commonjs",
"moduleResolution": "Node",
"ignoreDeprecations": "6.0",
"esModuleInterop": true,
"types": [
"mocha",
"node"
],
"outDir": "lib",
"sourceMap": true,
"strict": true,
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.publish.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"sourceMap": false
"sourceMap": false,
"rootDir": "src"
},
"include": [
"src/**/*"
Expand Down
Loading