Skip to content

Commit

Permalink
Merge pull request #392 from Freezystem/fix/remove-bluebird-from-mole…
Browse files Browse the repository at this point in the history
…culer-db

Remove bluebird from moleculer-db
  • Loading branch information
icebob authored Sep 30, 2024
2 parents ef97b43 + 82f1955 commit 29f8600
Show file tree
Hide file tree
Showing 10 changed files with 1,242 additions and 4,028 deletions.
5,106 changes: 1,149 additions & 3,957 deletions packages/moleculer-db-adapter-mongoose/package-lock.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions packages/moleculer-db/examples/encode/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"use strict";

let { ServiceBroker } = require("moleculer");
let DbService = require("../../index");
let _ = require("lodash");
let ModuleChecker = require("../../test/checker");
let Promise = require("bluebird");
const { ServiceBroker } = require("moleculer");
const DbService = require("../../index");
const _ = require("lodash");
const ModuleChecker = require("../../test/checker");

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

// Create broker
let broker = new ServiceBroker({
const broker = new ServiceBroker({
logger: console,
logLevel: "debug"
});
Expand Down Expand Up @@ -39,7 +40,7 @@ broker.createService(DbService, {
return this.adapter.count().delay(500).then(count => {
if (count == 0) {
this.logger.info("Seed products...");
let products = _.times(20, i => {
const products = _.times(20, i => {
return {
name: "Product " + i
};
Expand All @@ -58,7 +59,7 @@ const checker = new ModuleChecker(6);
// Start checks
function start() {
return Promise.resolve()
.delay(500)
.then(() => delay(500))
.then(() => checker.execute())
.catch(console.error)
.then(() => broker.stop())
Expand Down
31 changes: 15 additions & 16 deletions packages/moleculer-db/examples/pagination/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"use strict";

let _ = require("lodash");
let kleur = require("kleur");
let { ServiceBroker } = require("moleculer");
let DbService = require("../../index");
let ModuleChecker = require("../../test/checker");
let Promise = require("bluebird");
const _ = require("lodash");
const kleur = require("kleur");
const { ServiceBroker } = require("moleculer");
const DbService = require("../../index");
const ModuleChecker = require("../../test/checker");

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

// Create broker
let broker = new ServiceBroker({
const broker = new ServiceBroker({
logger: console,
logLevel: "debug"
});
Expand Down Expand Up @@ -42,7 +43,7 @@ const checker = new ModuleChecker(14);
// Start checks
function start() {
return Promise.resolve()
.delay(500)
.then(()=> delay(500))
.then(() => checker.execute())
.catch(console.error)
.then(() => broker.stop())
Expand All @@ -51,8 +52,6 @@ function start() {

// --- TEST CASES ---

let id;

// Count of posts
checker.add("COUNT", () => broker.call("posts.count"), res => {
console.log(res);
Expand All @@ -68,7 +67,7 @@ checker.add("FIND", () => broker.call("posts.find", { sort: "title" }), res => {
// List posts
checker.add("LIST FIRST 10", () => broker.call("posts.list", { sort: "title" }), res => {
console.log(res);
let rows = res.rows;
const rows = res.rows;
return [
res.total === 28 && res.page === 1 && res.pageSize === 10 && res.totalPages === 3,
rows.length === 10 && rows[0].title == "Post #01" && rows[9].title === "Post #10"
Expand All @@ -78,7 +77,7 @@ checker.add("LIST FIRST 10", () => broker.call("posts.list", { sort: "title" }),
// List posts
checker.add("LIST LAST 10", () => broker.call("posts.list", { sort: "-title" }), res => {
console.log(res);
let rows = res.rows;
const rows = res.rows;
return [
res.total === 28 && res.page === 1 && res.pageSize === 10 && res.totalPages === 3,
rows.length === 10 && rows[0].title == "Post #28" && rows[9].title === "Post #19"
Expand All @@ -88,7 +87,7 @@ checker.add("LIST LAST 10", () => broker.call("posts.list", { sort: "-title" }),
// List posts
checker.add("LIST FIRST 25", () => broker.call("posts.list", { page: 1, pageSize: 25, sort: "title" }), res => {
console.log(res);
let rows = res.rows;
const rows = res.rows;
return [
res.total === 28 && res.page === 1 && res.pageSize === 25 && res.totalPages === 2,
rows.length === 25 && rows[0].title == "Post #01" && rows[24].title === "Post #25"
Expand All @@ -98,7 +97,7 @@ checker.add("LIST FIRST 25", () => broker.call("posts.list", { page: 1, pageSize
// List posts
checker.add("LIST NEXT 25", () => broker.call("posts.list", { page: 2, pageSize: 25, sort: "title" }), res => {
console.log(res);
let rows = res.rows;
const rows = res.rows;
return [
res.total === 28 && res.page === 2 && res.pageSize === 25 && res.totalPages === 2,
rows.length === 3 && rows[0].title == "Post #26" && rows[2].title === "Post #28"
Expand All @@ -108,7 +107,7 @@ checker.add("LIST NEXT 25", () => broker.call("posts.list", { page: 2, pageSize:
// List posts
checker.add("LIST NEXT2 25", () => broker.call("posts.list", { page: 3, pageSize: 25, sort: "title" }), res => {
console.log(res);
let rows = res.rows;
const rows = res.rows;
return [
res.total === 28 && res.page === 3 && res.pageSize === 25 && res.totalPages === 2,
rows.length === 0
Expand All @@ -118,7 +117,7 @@ checker.add("LIST NEXT2 25", () => broker.call("posts.list", { page: 3, pageSize
// List posts with search
checker.add("LIST SEARCH 5", () => broker.call("posts.list", { page: 1, pageSize: 5, search: "#2" }), res => {
console.log(res);
let rows = res.rows;
const rows = res.rows;
return [
res.total === 9 && res.page === 1 && res.pageSize === 5 && res.totalPages === 2,
rows.length === 5
Expand Down
17 changes: 9 additions & 8 deletions packages/moleculer-db/examples/populates/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"use strict";

let { ServiceBroker } = require("moleculer");
let DbService = require("../../index");
let path = require("path");
let ModuleChecker = require("../../test/checker");
let Promise = require("bluebird");
const { ServiceBroker } = require("moleculer");
const DbService = require("../../index");
const path = require("node:path");
const ModuleChecker = require("../../test/checker");

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

// Create broker
let broker = new ServiceBroker({
const broker = new ServiceBroker({
logger: console,
logLevel: "debug"
});
Expand Down Expand Up @@ -108,7 +109,7 @@ const checker = new ModuleChecker(13);
// Start checks
function start() {
return Promise.resolve()
.delay(500)
.then(()=> delay(500))
.then(() => checker.execute())
.catch(console.error)
.then(() => broker.stop())
Expand Down Expand Up @@ -148,7 +149,7 @@ checker.add("GET POST (page: 2, pageSize: 5, sort: -votes)", () => broker.call("

checker.add("LIST POSTS (page: 2, pageSize: 5, sort: -votes)", () => broker.call("posts.list", { page: 2, pageSize: 2, sort: "-votes", populate: ["author"], fields: ["_id", "title", "votes", "author"] }), res => {
console.log(res);
let rows = res.rows;
const rows = res.rows;
return [
res.total === 5 && res.page === 2 && res.pageSize === 2 && res.totalPages === 3,
rows.length == 2,
Expand Down
7 changes: 4 additions & 3 deletions packages/moleculer-db/examples/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const kleur = require("kleur");
const { ServiceBroker } = require("moleculer");
const DbService = require("../../index");
const ModuleChecker = require("../../test/checker");
const Promise = require("bluebird");

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

// Create broker
const broker = new ServiceBroker({
Expand Down Expand Up @@ -53,7 +54,7 @@ const checker = new ModuleChecker(15);
// Start checks
function start() {
return Promise.resolve()
.delay(500)
.then(()=> delay(500))
.then(() => checker.execute())
.catch(console.error)
.then(() => broker.stop())
Expand All @@ -63,7 +64,7 @@ function start() {
// --- TEST CASES ---

let id;
let date = new Date();
const date = new Date();

// Count of posts
checker.add("COUNT", () => broker.call("posts.count"), res => {
Expand Down
15 changes: 10 additions & 5 deletions packages/moleculer-db/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/moleculer-db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
},
"dependencies": {
"@seald-io/nedb": "^3.0.0",
"bluebird": "^3.7.2",
"flat": "^5.0.2",
"lodash": "^4.17.21"
}
Expand Down
Loading

0 comments on commit 29f8600

Please sign in to comment.