Does anyone know how to use mysql with botkit instead of mongodb?
I've tried installing Mysql for botkit as seen here https://www.npmjs.com/package/botkit-storage-mysql
and I added the code provided to my bot.js file.
How can I do a simple test to see if its working if this is working.
I can't enter mysql shell in the app folder via terminal, I'm guessing there's something wrong.
The app runs fine on node .
botkit-storage-mysql is not a general purpose storage module, it is coded specifically to store details of Slack sessions and it isn't suitable for anything else.
I have it running using MySQL just fine. You need to have the MySQL Middleware https://www.npmjs.com/package/botkit-storage-mysql.
Alternatively you can download the middleware from the github repo and modify it to suit your needs (if the license allows it). Put it in your middlewares directory and include it in your bot.js https://github.com/getforgex/botkit-storage-mysql/tree/master/src
Related
I am currently working on a project related to my university and I would like people from my organization to be able to see my progress. My hosting provides the ability to run Node.js server, however it's refering to the app.js file which NestJS project doesn't have as it's being run through the command line (npm run start). Is there any way to run such application, for example by creating an app.js file which would be able to run the command?
Thank you for any assistance with this case.
PS. Server is running Phusion Passenger.
Phusion Passenger error message
If the server expects an app.js file and can't be customized to use something else, then you could have an app.js in your root directory that requires('./dist/main.js') and that's it. This would mean that your hosting service has to build the typescript code to javascript first, but that's hopefully something supported. If it isn't then you can do
// app.js
require('ts-node').register(); // you can pass extra options here
require('./src/main.ts');
It's not something I'd immediately recommend, but it would make the project runnable.
Ok this my sound silly but i have no clue on how to publish node.js backend for website i made. I am new at this and i know how to publish a website there are plenty of websites that offer hosting and domain for some amount of money but i don't know about backend. For example let's say i have node.js backend that reads data from MySQL database and sends it to my local-hosted website. And let's say i have nodemon package installed so i run it with nodemon and everything works fine. My question is how to publish this nodejs app along with my website and database.
You should get a VPS (Virtual Private Server) with Docker, It is the best solution.
Just copy your node folder and put it on a node docker image!
Got html front end? Just put it on an nginx docker image.
MySQL too, almost everything is possible with docker!
Want to learn more about docker? Here
Look into Heroku. Easy to use, mantain and deploy. You could either deploy from GitHub repo or directly via heroku.
Look into it here [https://devcenter.heroku.com/articles/deploying-nodejs]
I'm new to Reactjs, Nodejs and MongoDB. I'm currently trying to change Mediums snowflake tool to store users scores in a database. I have installed yarn, mongodb and mongodb-core through npm. It is a single page web application which is what I think is causing me trouble. I add
var MongoClient = require('mongodb');
To SnowflakeApp.js and encounter the following error:
Module not found: Error: Can't resolve 'dns' in
'/home/mlAHO174/snowflake/node_modules/mongodb-core/lib'
I've tried googling this error and have discovered it could be a range of things. I'm not sure if it is because React is front end and I'm trying to alter back end or because mongoDB is installed incorrectly. I'm new to this so would be grateful for help!
DNS is a core module of Node.JS. Telling people they need to install DNS via NPM will end up with them having a completely different module that does something else.
https://nodejs.org/api/dns.html vs https://www.npmjs.com/package/dns
This error most likely means you are trying to do something from the client-side that needs to be done on the server-side. If MongoDB module can't find the DNS component, it's running on the client-side.
MongoDB has to run on the server. In order to access data from React dynamically you'll need to set up an API using something like Express or Apollo.
Update:
A great way to do this is with Azure Functions (TypeScript) or AWS (Lambda) functions
For anyone who encounters this Error while importing the clientPromise (like in the with-mongodb template):
Make sure you're in the /pages/ directory!
It won't work in other directories like /components.
(and you should take a break or get some coffee...)
The problem is that you are trying to connect to the database from the front end. If this were possible that would open up a whole world of security issues. You need to set up your database connections on the backend and then have the front end make requests to the backend to handle the database.
I solved this by installing and using 'bson' instead of 'mongodb' for the client part of the code. 'bson' has a tiny bit of what 'mongodb' has and it might have what you are looking for. 'bson' is built for the browser.
In my case I needed the "ObjectId" in the browser and pulling it in from 'bson' did the trick as I didn't want to reference 'mongodb' because of the error described in the OP.
The other answers are also correct depending on why you're getting this error.
I think - mongo package is meant to be run on servers only, not in the browser.
It does not work in Next.js pages file components too, but does work in getStaticProps, getServerSideProps, getStaticPaths etc - because they run on the server, not the client.
Alternative - use Firebase Realtime database, you can access it in client-side code too. Example - a website (say a React app) that is hosted on GitHub pages or some other static server, but doesn't have a web app server (aka backend).
welcome to stack overflow.
You need to understand and learn few basics of web-applications. There's frontend, backend and a layer between them and a layer between backend and database. Frontend includes react.js, angular.js or anything else that is on browser. Backend is used to take request from frontend, providing API's to frontend and ask for data from other API's or database. Database includes sql, no-sql.
The error you are facing if of a NPM module mongodb-core.js. Either it's not installed properly, or installed using wrong version of module which is not comparable with your node version, or wrong version of NPM, or module using another NPM module which is not installed.
The issue in your case is mongodb-core uses a module dns which is not been installed. Try to install dns with npm i dns. or remove and install mongodb-core again.
I have a electron app, and I use it together with the create-electron-app.
My electron main process file resides in the public folder, and so does my sqlite3 database.
When I reference the database in development it works as expected because I can access the path:
F:\www\project-name\public\api\db\demodb01
But in production the path does not exist (hidden behind app.asar I'd say):
C:\Users\userName\AppData\Local\Programs\project-name\resources\app.asar\build\api\db\demodb01
How can I target the database file in production?
When storing files in your application you should use app.getPath('userData') to store them outside of your applications scope, which keeps them persisted.
nedb is a common choice for Electron applications since it's a lightweight database written in JavaScript. If you haven't checked it out, I recommend you to do.
You have one another solution. Please follow the below steps:
First Install electron-is-dev
Add these codes inside your main.js file:
main.js
Now in package.json make the following marked changes:
package.json
Thank you.
I tried to export a settings.json as documented in the meteor.js documentation in order to connect my Meteor.js app with an external MongoHQ database :
{
"env": {
"MONGO_URL" : "mongodb://xxx:xxxx#troup.mongohq.com:10037/xxx"
}
}
with the command :
mrt deploy myapp.meteor.com --settings settings.json
It doesn't even work, My app continue to connect the local database provided with the Meteor.app !
My MONGO_URL env variable didnt changed.
Is there any solution to export my MONGO_URL env variable to connect an external MongoDB database ?
I saw that is possible to change it while using heroku or modulus, what about the standard deploying meteor.com solution ?
You are not able to use your own MONGO_URL with Meteor deploy hosting.
Meteor deploy hosting takes care of the Email with Mailgun (if you use it), and provides mongodb for all apps deployed there.
It is possible to change the MAIL_URL, but it is not possible to use a different mongodb.
You can try, though im not sure it will work:
Place this in your server side code somewhere
process.env.MONGO_URL = '..';
Create a lib folder under the server folder and write:
Meteor.settings = { //your settings };
According to documentation everything inside a folder named lib will be executed before anything, so this way we ensure that no code will be execute before this, preventing errors from accessing Metrics that don't exist.
If you're already using the lib folder you've to named right to run before anything else that might conflict, check the docs about it.
Enjoy.
The application-configuration package (built in meteor package) contains the code to set mongo_url. See my answer here https://stackoverflow.com/a/23485319/2391620
Regarded to the Unoficial Meteor.js FAQ, thats not possible to do it easily, that might be tricky.
So i signed up for a modulus Account, with MongoHQ Database.
It works right now.
having a settings.json file is not enough you need to run with
meteor --settings settings.json
which is you cant do with meteor.com deploy.