Skip to content

Commit

Permalink
Restore CommonJS compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
T-vK committed Mar 7, 2024
1 parent 68ca6e4 commit ef92047
Show file tree
Hide file tree
Showing 31 changed files with 2,713 additions and 1,549 deletions.
28 changes: 11 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "express-restify-mongoose",
"version": "8.0.0",
"version": "8.0.1",
"description": "Easily create a flexible REST interface for mongoose models",
"keywords": [
"ReST",
Expand All @@ -23,33 +23,27 @@
"name": "Florian Holzapfel",
"email": "flo.holzapfel@gmail.com"
},
"type": "module",
"exports": {
"import": "./dist/express-restify-mongoose.js",
"require": "./dist/cjs/express-restify-mongoose.js"
},
"main": "./dist/cjs/express-restify-mongoose.js",
"main": "./dist/express-restify-mongoose.js",
"files": [
"dist/"
],
"scripts": {
"build": "run-p build:*",
"build:esm": "swc src --out-dir dist",
"build:cjs": "swc src --config module.type=commonjs --out-dir dist/cjs",
"build:cjs": "swc src --config module.type=commonjs --out-dir dist",
"build:dts": "tsup src/express-restify-mongoose.ts --dts-only",
"lint": "eslint . --ext .js,.ts",
"test": "run-s test:*",
"test:express": "mocha -R spec ./test/express.js --timeout 10s",
"test:filter": "mocha -R spec ./test/integration/resource_filter.js --timeout 10s",
"test:restify": "mocha -R spec ./test/restify.js --timeout 10s",
"test:unit": "mocha -R spec ./test/unit.js",
"test:express": "mocha -R spec ./test/express.mjs --timeout 10s",
"test:filter": "mocha -R spec ./test/integration/resource_filter.mjs --timeout 10s",
"test:restify": "mocha -R spec ./test/restify.mjs --timeout 10s",
"test:unit": "mocha -R spec ./test/unit.mjs",
"tsc": "tsc --noEmit"
},
"dependencies": {
"dot-prop": "^7.2.0",
"dot-prop": "^6.0.0",
"lodash.isplainobject": "~4.0.6",
"mongoose": "6.x",
"serialize-error": "^11.0.0",
"serialize-error": "^8.1.0",
"zod": "^3.19.1"
},
"devDependencies": {
Expand All @@ -62,7 +56,7 @@
"body-parser": "^1.19.0",
"esbuild": "^0.15.12",
"eslint": "^8.25.0",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-mocha": "10.3.0",
"express": "^4.17.1",
"method-override": "^3.0.0",
"mocha": "^10.1.0",
Expand All @@ -77,4 +71,4 @@
"engines": {
"node": ">=14"
}
}
}
3 changes: 2 additions & 1 deletion src/resource_filter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { getProperty, hasProperty } from "dot-prop";
import dotProp from "dot-prop";
import mongoose from "mongoose";
import { detective } from "./detective.js";
import { QueryOptions } from "./getQuerySchema.js";
import { Access, ExcludedMap, FilteredKeys } from "./types";
import { weedout } from "./weedout.js";
const { get: getProperty, has: hasProperty } = dotProp; // Because we're using an older version of dotProp that supports CommonJS

export class Filter {
excludedMap: ExcludedMap = new Map();
Expand Down
22 changes: 11 additions & 11 deletions test/express.js → test/express.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import bodyParser from "body-parser";
import express from "express";
import methodOverride from "method-override";

import accessTests from "./integration/access.js";
import contextFilterTests from "./integration/contextFilter.js";
import createTests from "./integration/create.js";
import deleteTests from "./integration/delete.js";
import hookTests from "./integration/hooks.js";
import middlewareTests from "./integration/middleware.js";
import optionsTests from "./integration/options.js";
import readTests from "./integration/read.js";
import updateTests from "./integration/update.js";
import virtualsTests from "./integration/virtuals.js";
import accessTests from "./integration/access.mjs";
import contextFilterTests from "./integration/contextFilter.mjs";
import createTests from "./integration/create.mjs";
import deleteTests from "./integration/delete.mjs";
import hookTests from "./integration/hooks.mjs";
import middlewareTests from "./integration/middleware.mjs";
import optionsTests from "./integration/options.mjs";
import readTests from "./integration/read.mjs";
import updateTests from "./integration/update.mjs";
import virtualsTests from "./integration/virtuals.mjs";

import setupDb from "./integration/setup.js";
import setupDb from "./integration/setup.mjs";

const db = setupDb();

Expand Down
2 changes: 1 addition & 1 deletion test/integration/access.js → test/integration/access.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from "assert";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from "assert";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
2 changes: 1 addition & 1 deletion test/integration/create.js → test/integration/create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mongoose from "mongoose";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
2 changes: 1 addition & 1 deletion test/integration/delete.js → test/integration/delete.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mongoose from "mongoose";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
2 changes: 1 addition & 1 deletion test/integration/hooks.js → test/integration/hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from "assert";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import request from "request";
import sinon from "sinon";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down Expand Up @@ -921,6 +921,7 @@ export default function (createFn, setup, dismantle) {
name: "ValidatorError",
path: "name",
properties: {
fullPath: "name",
message: "Path `name` is required.",
path: "name",
type: "required",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import request from "request";
import sinon from "sinon";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
2 changes: 1 addition & 1 deletion test/integration/read.js → test/integration/read.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mongoose from "mongoose";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from "assert";
import mongoose from "mongoose";
import { Filter } from "../../dist/resource_filter.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

const db = setupDb();

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/integration/update.js → test/integration/update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mongoose from "mongoose";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from "assert";
import request from "request";
import { serve } from "../../dist/express-restify-mongoose.js";

import setupDb from "./setup.js";
import setupDb from "./setup.mjs";

export default function (createFn, setup, dismantle) {
const db = setupDb();
Expand Down
22 changes: 11 additions & 11 deletions test/restify.js → test/restify.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import restify from "restify";

import accessTests from "./integration/access.js";
import contextFilterTests from "./integration/contextFilter.js";
import createTests from "./integration/create.js";
import deleteTests from "./integration/delete.js";
import hookTests from "./integration/hooks.js";
import middlewareTests from "./integration/middleware.js";
import optionsTests from "./integration/options.js";
import readTests from "./integration/read.js";
import updateTests from "./integration/update.js";
import virtualsTests from "./integration/virtuals.js";
import accessTests from "./integration/access.mjs";
import contextFilterTests from "./integration/contextFilter.mjs";
import createTests from "./integration/create.mjs";
import deleteTests from "./integration/delete.mjs";
import hookTests from "./integration/hooks.mjs";
import middlewareTests from "./integration/middleware.mjs";
import optionsTests from "./integration/options.mjs";
import readTests from "./integration/read.mjs";
import updateTests from "./integration/update.mjs";
import virtualsTests from "./integration/virtuals.mjs";

import setupDb from "./integration/setup.js";
import setupDb from "./integration/setup.mjs";

const db = setupDb();

Expand Down
12 changes: 0 additions & 12 deletions test/unit.js

This file was deleted.

12 changes: 12 additions & 0 deletions test/unit.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "./unit/buildQuery.mjs";
import "./unit/detective.mjs";
import "./unit/errorHandler.mjs";
import "./unit/middleware/access.mjs";
import "./unit/middleware/ensureContentType.mjs";
import "./unit/middleware/onError.mjs";
import "./unit/middleware/outputFn.mjs";
import "./unit/middleware/prepareOutput.mjs";
import "./unit/middleware/prepareQuery.mjs";
import "./unit/moredots.mjs";
import "./unit/resourceFilter.mjs";
import "./unit/weedout.mjs";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert";
import { Filter } from "../../dist/resource_filter.js";

import setupDb from "../integration/setup.js";
import setupDb from "../integration/setup.mjs";

describe("resourceFilter", () => {
describe("filterObject", () => {
Expand Down
File renamed without changes.
Loading

0 comments on commit ef92047

Please sign in to comment.