@amplication/plugin-db-mongo
Advanced tools
Comparing version
{ | ||
"host": "localhost", | ||
"port": 5432, | ||
"port": 27017, | ||
"user": "admin", | ||
"password": "admin" | ||
"password": "admin", | ||
"dbName": "my-db" | ||
} |
{ | ||
"name": "@amplication/plugin-db-mongo", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "Use a Mongo database in a service generated by Amplication", | ||
@@ -14,3 +14,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@amplication/code-gen-types": "^1.1.21", | ||
"@amplication/code-gen-types": "^1.1.25", | ||
"@babel/parser": "^7.18.11", | ||
@@ -17,0 +17,0 @@ "@babel/types": "^7.18.10", |
@@ -1,17 +0,4 @@ | ||
import { | ||
CreateServerDockerComposeParams, | ||
VariableDictionary, | ||
} from "@amplication/code-gen-types"; | ||
import { CreateServerDockerComposeParams } from "@amplication/code-gen-types"; | ||
import { DataSource, DataSourceProvider } from "prisma-schema-dsl-types"; | ||
export const envVariables: VariableDictionary = [ | ||
{ DB_USER: "${dbUser}" }, | ||
{ DB_PASSWORD: "${dbPassword}" }, | ||
{ DB_PORT: "27017" }, | ||
{ | ||
DB_URL: | ||
"mongodb://${dbUser}:${dbPassword}@${dbHost}:27017/dbName?authSource=admin", | ||
}, | ||
]; | ||
export const updateDockerComposeProperties: CreateServerDockerComposeParams["updateProperties"] = | ||
@@ -18,0 +5,0 @@ [ |
@@ -1,28 +0,28 @@ | ||
import { resolve } from "path"; | ||
import { | ||
dataSource, | ||
envVariables, | ||
updateDockerComposeProperties, | ||
} from "./constants"; | ||
import { | ||
DsgContext, | ||
AmplicationPlugin, | ||
CreatePrismaSchemaParams, | ||
CreateSchemaFieldResult, | ||
CreateServerDockerComposeDBParams, | ||
CreateServerDockerComposeParams, | ||
CreateServerDotEnvParams, | ||
CreatePrismaSchemaParams, | ||
CreateServerPackageJsonParams, | ||
CreateServerParams, | ||
DsgContext, | ||
Entity, | ||
EntityField, | ||
EnumDataType, | ||
Events, | ||
EnumDataType, | ||
EntityField, | ||
Entity, | ||
LoadStaticFilesParams, | ||
LookupResolvedProperties, | ||
CreateSchemaFieldResult, | ||
CreateServerPackageJsonParams, | ||
CreateServerParams, | ||
Module, | ||
PluginInstallation, | ||
types, | ||
} from "@amplication/code-gen-types"; | ||
import { ScalarType, ReferentialActions } from "prisma-schema-dsl-types"; | ||
import * as PrismaSchemaDSL from "prisma-schema-dsl"; | ||
import { camelCase } from "camel-case"; | ||
import { pascalCase } from "pascal-case"; | ||
import { resolve } from "path"; | ||
import * as PrismaSchemaDSL from "prisma-schema-dsl"; | ||
import { ReferentialActions, ScalarType } from "prisma-schema-dsl-types"; | ||
import { name } from "../package.json"; | ||
import { dataSource, updateDockerComposeProperties } from "./constants"; | ||
@@ -51,2 +51,5 @@ class MongoPlugin implements AmplicationPlugin { | ||
}, | ||
LoadStaticFiles: { | ||
after: this.afterCreateServerStaticFiles, | ||
}, | ||
}; | ||
@@ -100,4 +103,17 @@ } | ||
) { | ||
eventParams.envVariables = [...eventParams.envVariables, ...envVariables]; | ||
const { settings } = currentInstallation(context.pluginInstallations); | ||
const { port, password, user, host, dbName } = settings; | ||
eventParams.envVariables = [ | ||
...eventParams.envVariables, | ||
...[ | ||
{ DB_USER: user }, | ||
{ DB_PASSWORD: password }, | ||
{ DB_PORT: port }, | ||
{ | ||
DB_URL: `mongodb://${user}:${password}@${host}:${port}/${dbName}?authSource=admin`, | ||
}, | ||
], | ||
]; | ||
return eventParams; | ||
@@ -132,2 +148,20 @@ } | ||
async afterCreateServerStaticFiles( | ||
context: DsgContext, | ||
eventParams: LoadStaticFilesParams, | ||
modules: Module[] | ||
) { | ||
const staticPath = resolve(__dirname, "./static/health"); | ||
const staticsFiles = await context.utils.importStaticModules( | ||
staticPath, | ||
`${context.serverDirectories.srcDirectory}/health/base` | ||
); | ||
const updateModules = modules.filter( | ||
(x) => !x.path.includes("health.service.base") | ||
); | ||
return [...staticsFiles, ...updateModules]; | ||
} | ||
beforeCreatePrismaSchema( | ||
@@ -302,1 +336,14 @@ context: DsgContext, | ||
export default MongoPlugin; | ||
function currentInstallation( | ||
pluginInstallations: PluginInstallation[] | ||
): PluginInstallation { | ||
const plugin = pluginInstallations.find((plugin, i) => { | ||
return plugin.npm === name; | ||
}); | ||
if (!plugin) { | ||
throw new Error("Missing plugin installation"); | ||
} | ||
return plugin; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
175224
3.99%15
15.38%1928
5.36%