Strapi 4.1.5 email plugin configuration - email

Unable to change email configuration. I specify the settings according to the instructions.
Restarted the server.
Removed cache and node_modules
In any case, the default plugin configuration is used.
node v14.18.2
strapi 4.1.5
{
"name": "strapi-test",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"#strapi/plugin-i18n": "4.1.5",
"#strapi/plugin-users-permissions": "4.1.5",
"#strapi/provider-email-nodemailer": "^4.1.5",
"#strapi/strapi": "4.1.5",
"sqlite3": "5.0.2"
},
"author": {
"name": "A Strapi developer"
},
"strapi": {
"uuid": "87e9d8e3-8c82-4c8e-8de4-990c2b729be4"
},
"engines": {
"node": ">=12.x.x <=16.x.x",
"npm": ">=6.0.0"
},
"license": "MIT"
}
SOLUTION https://github.com/strapi/strapi/issues/12919#issuecomment-1075954840

in case anyone looking for the answer for this.
like derick says, in strapi v4 the provider and providerOptions need to be wrapped inside config.
like this
module.exports = ({ env }) => ({
// ...
email: {
config: {
provider: 'nodemailer',
providerOptions: {
host: env('SMTP_HOST', 'smtp.gmail.com'),
port: env('SMTP_PORT', 465),
auth: {
user: env('SMTP_USERNAME', 'email#gmail.com'),
pass: env('SMTP_PASSWORD', 'password'),
},
},
settings: {
defaultFrom: 'email#gmail.com',
defaultReplyTo: 'email#gmail.com',
},
},
},
// ...
});

Related

VS Code not debugging with different angular configuration

I created a new configuration in my angular.json and I cannot make VS Code debug.
My VS Code is debugging OK when I use the default configuration.
I created a new configuraton in angular.json as below:
{
...
},
"newProjectRoot": "projects",
"projects": {
"MyProject": {
"projectType": "application",
"schematics": {
...
},
...
"architect": {
"build": {
...,
"configurations": {
"production": {
...
},
"development": {
...
},
"fred": { <================================================
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.fred.ts"
}
]
}
},
"defaultConfiguration": "development"
},
"serve": {
...,
"configurations": {
"production": {
"browserTarget": "fuse:MyProject:production"
},
"development": {
"browserTarget": "fuse:MyProject:development"
},
"fred": { <=====================================================
"browserTarget": "fuse:MyProject:fred"
}
},
"defaultConfiguration": "development"
},
...
}
}
}
}
On package.json I created a new script
"scripts": {
"ng": "ng",
"start": "ng serve --port 8093",
"start-fred": "ng serve --configuration fred --port 8093", <====================
...
}
On my launch.json I added a new config to start that script
{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve Chrome",
...
},
{
"name": "Fred ng serve Chrome",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start-fred", <=================================
"url": "https://localhost:8093",
"webRoot": "${workspaceFolder}"
},
{
"name": "ng serve Edge",
...
}
]
}
It builds OK and I can navigate the app by manually going to the URL on the browser but I cannot debug. VS Code hangs with no error message and never starts the debug session.
I don't know where else to look. As I said before, I can debug OK when I use the default (development) configuration

Cypress Connecting to postgres database issue

running into a issue using cypress-postgres connecting to the database. Server has multiple databases along with multiple schemas. Tried multiple plugins, but can find a solution that will allow me to specify a particular schema in a database. Server is reachable over the vpn.
Will need to do this with sql database. Any help, better method suggestions welcomed.
Thank You! - Michael Frazier
IE: Database Example.
Error that is returned
no relation for home
Package.json has following dependencies:
name": "tests",
"version": "1.0.0",
"description": "Automated Tests",
"main": "index.js",
"scripts": {
"cypress:open": "cypress open",
"test": "cypress open"
},
"repository": {
"type": "git",
"url":
},
"author": "Michael Frazier
"license": "ISC",
"dependencies": {
"#testing-library/cypress": "^8.0.2",
"#testing-library/vue": "^5.8.2",
"#vue/test-utils": "^1.3.0",
"cypress-commands": "^2.0.1",
"cypress-downloadfile": "^1.2.1",
"cypress-postgres": "^1.1.1",
"cypress-postgresql": "^1.0.8",
"cypress-real-events": "^1.6.0",
"pg": "^8.7.1",
"pg-promise": "^10.5.8",
"yarn": "^1.22.17"
},
"devDependencies": {
"#4tw/cypress-drag-drop": "^2.1.0",
"#babel/core": "^7.15.0",
"#babel/preset-env": "^7.15.0",
"#cypress/skip-test": "^2.6.1",
"#cypress/webpack-preprocessor": "^5.9.1",
"#testing-library/dom": "^8.11.2",
"#types/chai": "^4.2.21",
"#types/jest": "^27.0.1",
"#types/mocha": "^9.0.0",
"cy-mobile-commands": "^0.3.0",
"cypress": "^9.5.3",
"cypress-file-upload": "^5.0.8",
"cypress-fill-command": "^1.0.2",
"cypress-iframe": "^1.0.1",
"cypress-mailosaur": "^2.6.0",
"cypress-mochawesome-reporter": "^2.4.0",
"cypress-msteams-reporter": "^1.0.3",
"cypress-plugin-tab": "^1.0.5",
"cypress-wait-until": "^1.7.2",
"dayjs": "^1.10.6",
"faker": "^5.5.3",
"mysql": "^2.18.1",
"pdf-parse": "^1.1.1",
"webpack": "^5.51.1"
}
}
Cypress.json has DB credentials in following format:
{
"trashAssetsBeforeRuns": true,
"responseTimeout": 30000,
"requestTimeout": 50000,
"defaultCommandTimeout": 4000,
"experimentalSourceRewriting": true,
"experimentalStudio": true,
"projectId": "aycmk8",
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"reportDir": "cypress/report",
"charts": true,
"reportPageTitle": "Melos Report"
},
"db":
{"user": "postgres",
"host": "",
"database": "",
"password": "",
"schemas": "sct",
"port": 5432
}
}
Plugin in cypress\plugins\index.js file:
module.exports = async (on, config) => {
on('task',
{dbQuery: (query)=> require('cypress-postgres')(query.query,query.connection)})
Spec file has following test:
describe("Database Health Tests", function () {
it('should ping the database to ensure its active ', function () {
cy.task("dbQuery", {"query":"select * from home"})
});
Your dbQuery is missing the connection string:
cy.task("dbQuery",
{
query: "select * from home",
connection: "your connection string"
})
If you focusing on description of cypress-postgres in npm, they provided 2-ways to use :
The first way : load your database connection via cypress.json by require('cypress-postgres').
The seconds way : set your database connection by yourself in cy.task.
The first way
This way may make you mistake, the example shows unclear parameter to you :
// In cypress\plugins\index.js
module.exports = on => {
on("task", {
dbQuery:(query)=> require("cypress-postgres")(query.query,query.connection)
});
};
I'm not sure query.connection come from. If you access to the dependency, you will see :
// In require('cypress-postgres')
const pgp = require('pg-promise')();
const postgressConfig = require(require('path').resolve('cypress.json'));
module.exports = function(query,userDefineConnection) {
let connection = postgressConfig.db
if (userDefineConnection!=undefined){
connection=userDefineConnection
}
const db = pgp(connection);
return db.any(query)
}
So you can change query.connection to your variable.
Normally, module in cypress\plugins\index.js received 2-arguments on and config. The config will refer to cypress.json, you can get your database connection via config.env.db :
{
"env": {
"db": {
"user": "postgres",
"host": "localhost",
"database": "postgres",
"password": "mysecretpassword",
"port":5432
}
}
}
Now cypress\plugins\index.js should be :
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on("task", {
dbQuery: (query) => require("cypress-postgres")(query.query, config.env.db)
})
}
In your *.spec.js :
// ...
it('set "Y" to db', () => {
cy.task("dbQuery", { "query": "select count(*) as num_row from home"
}).then(result => {
expect(result[0].num_row).to.equal('1')
})
})
// ...
The seconds way
This way assign database connection directly in your *.spec.js :
// ...
it('set "Y" to db', () => {
cy.task("dbQuery", {
"query": "select count(*) as num_row from home",
"connection": {
"user": "postgres",
"host": "localhost",
"database": "postgres",
"password": "mysecretpassword",
"port":5432
}
}).then(result => {
expect(result[0].num_row).to.equal('1')
})
})
// ...

Can we combine two presets MongoDB and puppeteer in Jest?

Currently I am using Jest with puppeteer and I want combine that with MongoDB, is it possible to do that?
Here is my package.json look like:
{
"name": "testing",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"jest": {
"preset": "jest-puppeteer",
"testMatch": [
"**/tests/**/*.test.js"
],
"testTimeout": 80000,
"verbose": true
}
}
and my jest-puppeteer.config.js looks like this
module.exports = {
launch: {
defaultViewport: {
width: 1420,
height: 1080,
},
devtools: false,
headless: process.env.HEADLESS !== 'false',
slowMo: process.env.SLOWMO ? process.env.SLOWMO : 0,
},
};
Now I want to add mongoDB connection to the project with some predefined config something like this.
module.exports = {
mongodbMemoryServerOptions: {
binary: {
version: '4.0.3',
skipMD5: true
},
autoStart: false,
instance: {}
}
};
How do I combine puppeteer and mongoDB?

Can't use EJS hook in Strapi showing error TypeError: ctx.render is not a function

What is the bug?
I am trying to render a page using strapi-hook-ejs but it is not working even I followed all official documentation.
It is giving following error
[2020-10-13T03:34:15.198Z] error TypeError: ctx.render is not a function
at Object.page (C:\Users\noman\Desktop\TestAPI\api\home\controllers\home.js:11:20)
at dispatch (C:\Users\noman\Desktop\TestAPI\node_modules\koa-router\node_modules\koa-compose\index.js:44:32)
at next (C:\Users\noman\Desktop\TestAPI\node_modules\koa-router\node_modules\koa-compose\index.js:45:18)
at dispatch (C:\Users\noman\Desktop\TestAPI\node_modules\koa-compose\index.js:42:32)
at C:\Users\noman\Desktop\TestAPI\node_modules\strapi\lib\middlewares\router\utils\routerChecker.js:79:28
at dispatch (C:\Users\noman\Desktop\TestAPI\node_modules\koa-compose\index.js:42:32)
at module.exports (C:\Users\noman\Desktop\TestAPI\node_modules\strapi-plugin-users-permissions\config\policies\permissions.js:86:9)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async C:\Users\noman\Desktop\TestAPI\node_modules\strapi-utils\lib\policy.js:68:5
at async serve (C:\Users\noman\Desktop\TestAPI\node_modules\koa-static\index.js:59:5)
at async C:\Users\noman\Desktop\TestAPI\node_modules\strapi\lib\middlewares\xss\index.js:26:9
[2020-10-13T03:34:15.212Z] debug GET /home/page (39 ms) 500
[2020-10-13T03:34:15.255Z] debug GET /favicon.ico (1 ms) 200
Steps to reproduce the behavior
I installed strapi-hook-ejs (npm i strapi-hook-ejs --save)
Create a new hook.json file in config folder. (./config/hook.json)
Added this code
{
"ejs": {
"enabled": true,
"layout": false,
"viewExt": "ejs",
"partial": true,
"cache": false,
"debug": true
}
}
Created views folder and a home.ejs file in it (./views/home.ejs) with this code <h1><%=title%></h1>
Then I created a new controller and point a route to it.
module.exports = {
page: async ctx => {
return ctx.render('home', {title: 'My app title'});
},
};
Now when I am going to this route I am getting the error.
Expected behavior
Should render home page
My Package.json
{
"name": "source-api",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"axios": "^0.20.0",
"strapi": "3.1.4",
"strapi-admin": "3.1.4",
"strapi-connector-mongoose": "3.1.4",
"strapi-hook-ejs": "^3.2.3",
"strapi-plugin-content-manager": "3.1.4",
"strapi-plugin-content-type-builder": "3.1.4",
"strapi-plugin-email": "3.1.4",
"strapi-plugin-upload": "3.1.4",
"strapi-plugin-users-permissions": "3.1.4",
"strapi-provider-upload-cloudinary": "^3.1.4",
"strapi-utils": "3.1.4"
},
"author": {
"name": "Nehal Ahmad"
},
"strapi": {
"uuid": "1034d7e9-73ba-49d4-8862-0d5d62ae7008"
},
"engines": {
"node": "12.x",
"npm": "6.x"
},
"license": "MIT"
}
System
Node.js version: v12.18.1
NPM version: 6.14.5
Strapi version: 3.1.4
Database: Mongo db
Operating system: Windows 10 pro
I have tried it on latest version of strapi.
I found answer on forum.strapi.io from user larsonnn
https://forum.strapi.io/t/cant-use-ejs-hook-showing-error-typeerror-ctx-render-is-not-a-function/416/9?u=nehal_ahmad

How to interact with Windows Authentication and Users group using React.js .Net

I am curious how one would interact with Windows Authentication using React.js.
We have a little internal portal we are trying to set up, we already have predefined users groups and users that are in them. We are looking for a way to get those Authenticated credentials to the view using React.js. There are a couple of good links on how to get started with Reactjs.net but I don't see any tutorials on passing credentials to Reactjs.
Any suggested reading? Tutorials or maybe you know yourself and can provide direction?
enter link description here
I've found this really cool tutorial!
It says:
Here’s a minimal setup for React and Webpack based on what we did in this article. Now that you understand the steps, you can copy-paste this to your heart’s content.
package.json
Note: agentkeepalive is only needed for fixing a Windows authentication error with Hot Module Replacement.
{
"name": "ReactWebPackMVC5",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server –open –hot"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.0.0",
"#babel/preset-env": "^7.0.0",
"#babel/preset-react": "^7.0.0",
"agentkeepalive": "^3.5.1",
"babel-loader": "^8.0.2",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"webpack": "^4.18.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
}
}
webpack.config.js
Again, agentkeepalive is only needed for fixing a Windows authentication error with Hot Module Replacement. The same is true for the agent and onProxyRes properties.
const path = require("path"); const agent = require("agentkeepalive")
module.exports = { mode: "development", entry: "./Scripts/react/app.js", //or app.jsx output: { path: path.resolve(__dirname, "./Scripts/react/dist"), filename: "bundle.js", publicPath: "Scripts/react/dist" }, resolve: { extensions: ["*", ".js", ".jsx"] }, module: { rules: [ { test: /\.(js|jsx)/, exclude: /node_modules/, use: { loader: "babel-loader", options: { “presets”: [“#babel/preset-env”, “#babel/preset-react”] } } } ] }, devServer: { proxy: { "*": { target: "http://localhost:59829", changeOrigin: true, agent: new agent({ maxSockets: 100, keepAlive: true, maxFreeSockets: 10, keepAliveMsecs: 100000, timeout: 6000000, keepAliveTimeout: 90000 // free socket keepalive for 90 seconds }), onProxyRes: (proxyRes) => { var key = "www-authenticate"; proxyRes.headers[key] = proxyRes.headers[key] && proxyRes.headers[key].split(","); }, }, port: 8080, host: "0.0.0.0", hot: true, }, } };