@amplication/plugin-db-mongo
Advanced tools
Comparing version 1.2.12 to 1.3.0
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
19
2
180935
2092