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

memserver

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memserver - npm Package Compare versions

Comparing version 2.2.5 to 2.3.0

34

dist/pretender-hacks.js

@@ -6,3 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const qs_1 = __importDefault(require("qs"));
const ansi_colors_1 = __importDefault(require("ansi-colors"));

@@ -28,9 +27,7 @@ const ember_inflector_1 = require("ember-inflector");

}, {});
var contentHeader = request.headers["Content-Type"] || request.headers["content-type"];
if (request.requestBody && contentHeader && contentHeader.includes("application/json")) {
request.params = nilifyStrings(Object.assign(request.params, JSON.parse(request.requestBody)));
let newParamsFromBody = tryConvertingJSONStringToObject(request.requestBody) ||
tryConvertingQueryStringToObject(request.requestBody);
if (newParamsFromBody) {
request.params = nilifyStrings(Object.assign(request.params, newParamsFromBody));
}
else {
request.params = nilifyStrings(Object.assign(request.params, qs_1.default.parse(request.requestBody)));
}
}

@@ -54,2 +51,25 @@ return match;

}
function tryConvertingJSONStringToObject(string) {
let object;
try {
object = JSON.parse(string);
}
catch (e) {
return false;
}
if (typeof object === "object" && object !== null) {
return object;
}
return false;
}
function tryConvertingQueryStringToObject(queryString) {
let result = {};
let entries = new URLSearchParams(queryString);
for (const [key, value] of entries) { // each 'entry' is a [queryParamKey, queryParamValue] tupple
result[key] = value;
}
if (Object.keys(result).length > 0) {
return result;
}
}
function nilifyStrings(value) {

@@ -56,0 +76,0 @@ if (value !== null && typeof value === "object") {

{
"name": "memserver",
"version": "2.2.5",
"version": "2.3.0",
"description": "in-memory database/ORM and http mock server you can run in-browser and node environments. Built for large frontend teams, fast tests and rapid prototyping",

@@ -10,6 +10,2 @@ "author": "Izel Nakri",

},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/memserver"
},
"license": "MIT",

@@ -20,5 +16,5 @@ "bin": {

"scripts": {
"typecheck": "tsc --project tsconfig.json --noEmit",
"dev": "tsc --watch",
"bin": "sh cli.sh",
"typecheck": "node_modules/.bin/tsc --project tsconfig.json --noEmit",
"dev": "node_modules/.bin/tsc --watch",
"bin": "src/cli.ts",
"test": "node_modules/.bin/ava --verbose",

@@ -30,2 +26,3 @@ "prepublishOnly": "npm run npm-link-ember-packages && tsc --build && npm run publish-modules-for-browser",

"dependencies": {
"@types/node": "^14.14.10",
"ansi-colors": "4.1.1",

@@ -36,6 +33,4 @@ "fake-xml-http-request": "^2.1.1",

"pretender": "^3.4.3",
"qs": "^6.9.4",
"route-recognizer": "^0.3.4",
"ts-node": "^9.0.0",
"@types/node": "^14.14.10"
"ts-node": "^9.0.0"
},

@@ -42,0 +37,0 @@ "devDependencies": {

@@ -218,7 +218,7 @@ <a href="https://circleci.com/gh/izelnakri/memserver/">

const serializedUserForEndpoint = User.serializer(user); // or User.serialize(user);
const serializedUserForEndpoint = { user: User.serializer(user); } // or User.serialize(user);
const users = User.findAll({ active: true });
const serializedUsersForEndpoint = User.serializer(users); // or users.map((user) => User.serialize(user));
const serializedUsersForEndpoint = { users: User.serializer(users); } // or users.map((user) => User.serialize(user));
```

@@ -249,7 +249,7 @@

const serializedUserForEndpoint = User.customSerializer(user); // or User.customSerialize(user);
const serializedUserForEndpoint = { user: User.customSerializer(user) }; // or User.customSerialize(user);
const users = User.findAll({ active: true });
const serializedUsersForEndpoint = User.customSerializer(users); // or users.map((user) => User.customSerialize(user));
const serializedUsersForEndpoint = { users: User.customSerializer(users); } // or users.map((user) => User.customSerialize(user));
```

@@ -275,4 +275,4 @@

runtimes. Autogenerating things after a model gets created is an implicit thus bad behavior. Validations could be done
in future as types or TS type decorators, thus validations won't happen in runtime and all would be check during
development via typescript typecheck/linting.
in future as types or TS type decorators(like `class-validator` npm package), thus validations don't need to happen in
runtime and all would be check during development via typescript typecheck/linting.

@@ -279,0 +279,0 @@ - No implicit relationship tracking, creating and updating a relationship should be done on the foreign-key of the

@@ -1,2 +0,1 @@

import qs from "qs";
import chalk from "ansi-colors";

@@ -28,10 +27,6 @@ import { singularize } from "ember-inflector";

var contentHeader = request.headers["Content-Type"] || request.headers["content-type"];
if (request.requestBody && contentHeader && contentHeader.includes("application/json")) {
request.params = nilifyStrings(
Object.assign(request.params, JSON.parse(request.requestBody))
);
} else {
request.params = nilifyStrings(Object.assign(request.params, qs.parse(request.requestBody)));
let newParamsFromBody = tryConvertingJSONStringToObject(request.requestBody) ||
tryConvertingQueryStringToObject(request.requestBody);
if (newParamsFromBody) {
request.params = nilifyStrings(Object.assign(request.params, newParamsFromBody));
}

@@ -57,2 +52,29 @@ }

function tryConvertingJSONStringToObject(string) {
let object;
try {
object = JSON.parse(string);
} catch (e) {
return false;
}
if (typeof object === "object" && object !== null) {
return object;
}
return false;
}
function tryConvertingQueryStringToObject(queryString) {
let result = {};
let entries = new URLSearchParams(queryString);
for (const [key, value] of entries) { // each 'entry' is a [queryParamKey, queryParamValue] tupple
result[key] = value;
}
if (Object.keys(result).length > 0) {
return result;
}
}
function nilifyStrings(value) {

@@ -59,0 +81,0 @@ if (value !== null && typeof value === "object") {

Sorry, the diff of this file is too big to display

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