X
X
Xenia2018-11-13 21:32:07
Node.js
Xenia, 2018-11-13 21:32:07

Correct app architecture for telegram bot on node js?

Hello! I am writing a bot for telegram on node js using telegraph.js, and mongoose. This is my first rake.
Now it's done like this:
- the app.js application and auxiliary files are posted on DigitalOcean in a dokku container
- the database is on a free mlab account
And everything seems to work, but: if something is updated in the database, but the container is not restarted, then if you request this data via telegram, they are not displayed, although they are definitely in the database. If you restart the container - the data appears.
In general, it looks like this (hereinafter - my guesses), as if the user is accessing my application - class instances are created, data is pulled from the database (once) - and that's it. Repeated commands use the old data.
And here is the question: how to properly organize the architecture for a bot on node? Should I have a server? any express? Do not restart the application after each change in the database ... And the most interesting thing is why the data is not updated again?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Neverov, 2018-11-13
@TTATPuOT

Yes, most likely it is. Check if caching is enabled and if data is being stored in global variables, which are then reused.
If you are using Webhooks, then you must have a server. Not necessarily Express. Just to receive notifications from Telegram.
But your problem is not related to the server or lack thereof. The first line of the answer is helpful. Search by repetition code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question