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

@amplication/plugin-db-mongo

Package Overview
Dependencies
Maintainers
7
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amplication/plugin-db-mongo - npm Package Compare versions

Comparing version 1.2.12 to 1.3.0

.prettierrc

4

package.json
{
"name": "@amplication/plugin-db-mongo",
"version": "1.2.12",
"version": "1.3.0",
"description": "Use a Mongo database in a service generated by Amplication",

@@ -55,2 +55,2 @@ "main": "dist/index.js",

}
}
}

@@ -12,5 +12,18 @@ import { CreateServerDockerComposeParams } from "@amplication/code-gen-types";

environment: {
DB_URL: "mongodb://${DB_USER}:${DB_PASSWORD}@db:27017",
DB_URL:
"mongodb://${DB_USER}:${DB_PASSWORD}@db:27017/${DB_NAME}?authSource=admin",
},
depends_on: ["migrate"],
},
migrate: {
environment: {
DB_URL:
"mongodb://${DB_USER}:${DB_PASSWORD}@db:27017/${DB_NAME}?authSource=admin",
},
depends_on: {
db: {
condition: "service_healthy",
},
},
},
db: {

@@ -22,3 +35,17 @@ image: "mongo",

MONGO_INITDB_ROOT_PASSWORD: "${DB_PASSWORD}",
MONGO_INITDB_DATABASE: "${DB_NAME}",
MONGO_REPLICA_SET_NAME: "rs0",
},
restart: "always",
entrypoint: [
"/bin/bash",
"-c",
"openssl rand -base64 741 > /data/cert.crt; chmod 400 /data/cert.crt && chown 999 /data/cert.crt; /usr/local/bin/docker-entrypoint.sh mongod --bind_ip_all --keyFile /data/cert.crt --replSet rs0",
],
healthcheck: {
test: "test $$(mongosh --quiet -u $${MONGO_INITDB_ROOT_USERNAME} -p $${MONGO_INITDB_ROOT_PASSWORD} --eval \"try { rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'db' }] }).ok } catch (_) { rs.status().ok }\") -eq 1",
start_period: "5s",
interval: "10s",
timeout: "10s",
},
volumes: [`${mongodbVolumeName}:/var/lib/mongosql/data`],

@@ -25,0 +52,0 @@ },

@@ -18,7 +18,5 @@ import {

Module,
PluginInstallation,
types,
} from "@amplication/code-gen-types";
import { camelCase } from "camel-case";
import { merge } from "lodash";
import { pascalCase } from "pascal-case";

@@ -28,6 +26,4 @@ import { resolve } from "path";

import { ReferentialActions, ScalarType } from "prisma-schema-dsl-types";
import defaultSettings from "../.amplicationrc.json";
import { name } from "../package.json";
import { dataSource, updateDockerComposeProperties } from "./constants";
import YAML from "yaml";
import { getPluginSettings } from "./utils";

@@ -45,3 +41,2 @@ class MongoPlugin implements AmplicationPlugin {

before: this.beforeCreateServerDockerCompose,
after: this.afterCreateServerDockerCompose,
},

@@ -109,10 +104,6 @@ CreateServerDockerComposeDB: {

) {
const { settings } = currentInstallation(context.pluginInstallations) || {
settings: {},
};
const { port, password, user, host, dbName } = getPluginSettings(
context.pluginInstallations
);
const fullSettings = merge(defaultSettings, settings);
const { port, password, user, host, dbName } = fullSettings;
eventParams.envVariables = [

@@ -123,3 +114,4 @@ ...eventParams.envVariables,

{ DB_PASSWORD: password },
{ DB_PORT: port },
{ DB_PORT: port.toString() },
{ DB_NAME: dbName },
{

@@ -134,19 +126,2 @@ DB_URL: `mongodb://${user}:${password}@${host}:${port}/${dbName}?authSource=admin`,

afterCreateServerDockerCompose(
dsgContext: DsgContext,
eventParams: CreateServerDockerComposeParams,
modules: Module[]
): Module[] {
const dockerCompose = modules[0];
const dockerComposeObject: { services: { migrate: { depends_on: any } } } =
YAML.parse(dockerCompose.code);
try {
dockerComposeObject.services.migrate.depends_on = undefined;
} catch (error) {}
const updatedDockerCompose = YAML.stringify(dockerComposeObject, {
nullStr: "~",
});
modules[0] = { ...dockerCompose, code: updatedDockerCompose };
return modules;
}
beforeCreateServerDockerCompose(

@@ -360,3 +335,3 @@ context: DsgContext,

if (fieldHasUniqueName || relatedFieldHasUniqueName) {
const names = [];
const names: string[] = [];
if (fieldHasUniqueName) {

@@ -384,11 +359,1 @@ names.push(field.name);

export default MongoPlugin;
function currentInstallation(
pluginInstallations: PluginInstallation[]
): PluginInstallation | undefined {
const plugin = pluginInstallations.find((plugin, i) => {
return plugin.npm === name;
});
return plugin;
}
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"lib": ["es2020", "dom"],
"sourceMap": true,
"baseUrl": "./src",
"outDir": "dist",
"incremental": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"strict": true,
"jsx": "react"
},
"include": ["src/index.ts"],
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"compilerOptions": {},
}

@@ -15,3 +15,6 @@ const path = require("path");

new CopyWebpackPlugin({
patterns: [{ from: "src/static", to: "static" }],
patterns: [
{ from: "src/static", to: "static", noErrorOnMissing: true },
{ from: "src/templates", to: "templates", noErrorOnMissing: true },
],
}),

@@ -29,3 +32,3 @@ ],

resolve: {
extensions: [".ts", ".js", ".json"],
extensions: [".ts", ".js"],
},

@@ -32,0 +35,0 @@ optimization: {

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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