adonis.js

How can I connect with X509 by putting all options in the connection string in node.js driver for mongodb?

白昼怎懂夜的黑 提交于 2021-02-05 09:20:07
问题 I'm using the keys available in mongodb docs for a self-signed certificate using X509 authentication with a Node.js Driver. When trying to connect to the database I get the following error: MongoNetworkError: failed to connect to server [pedro.com:57040] on first connect [MongoNetworkError: unable to verify the first certificate] Despite that error, I am sure that the connection works as I am using Studio 3T and everything is up and running by using the same certificates. So my question is...

Create Javascript Object Having Nested Parent Objects

ⅰ亾dé卋堺 提交于 2021-02-05 07:57:27
问题 I am working on a Nodejs project. I have to create a function which takes an object (a child category) like: { id: 65, name: 'Outdoor', parent_id: 2 } Now I want my function to check for the parent category by using parent_id from database and return an array/object like this: { id: 2, name: 'Furniture', parent: { id: 1, name: 'Residential', parent: { id: ..., name: ..., parent: { and so on.. } } } } This is what I have done so far: * _get_category_parents(category, _array) { if(_array ===

How can i debugging my adonis ( nodejs ) framework APIs?

二次信任 提交于 2021-01-29 13:37:28
问题 I'm just beginner in adonis framework in NodeJS but I have a good experience in laravel and lumen framework in laravel and lumen framework APIs I use dd() dump and die to debugging my app but in the AONIS framework, I don't know how to debug my API code . for IDE = I'm using Microsoft visual studio ( VS Code ) 回答1: Read this : https://code.visualstudio.com/docs/nodejs/nodejs-debugging (from @damitj07) In summary : You need to create new lauch.json like: { // Use IntelliSense to learn about

How can I use a command from another container using Docker Compose?

爷,独闯天下 提交于 2021-01-28 06:07:10
问题 I have two Dockerfiles: one for adonis (with node docker's hub image) and another for mongo (with mongo docker's hub image). The mongo_service must depend on adonis service because I only want to run adonis after starting all the mongo instances. Therefore, on the end of the mongo dockerfile I run a script which in the end will run: adonis seed adonis serve The error that I'm having is: adonis: command not found I understand that somehow the mongo_service is not having access to the adonis

How can I solve error gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config?

一个人想着一个人 提交于 2020-08-24 05:27:47
问题 I want to run this project : https://github.com/adonis-china/adonis-adminify When I run npm install , there exist error : > sqlite3@3.1.13 install C:\laragon\www\adonis-admin\node_modules\sqlite3 > node-pre-gyp install --fallback-to-build node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-win32-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.13 and node@10.15.0 (node-v64 ABI) (falling back to source compile

How can I solve error gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config?

醉酒当歌 提交于 2020-08-24 05:27:41
问题 I want to run this project : https://github.com/adonis-china/adonis-adminify When I run npm install , there exist error : > sqlite3@3.1.13 install C:\laragon\www\adonis-admin\node_modules\sqlite3 > node-pre-gyp install --fallback-to-build node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-win32-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.13 and node@10.15.0 (node-v64 ABI) (falling back to source compile

How to validate multipart file on AdonisJS?

纵然是瞬间 提交于 2019-12-13 03:35:15
问题 I am using Adonis.js in the latest version but cannot validate... Already tried request.multipart.file('avatar', { types: ['jpeg', 'jpg', 'png'], // I already tried -> type: ['image'] types: ['image'], size: "4mb" }, async file => { await Drive.put(key, file.stream) }) .../Validators/changeAvatar.js 'use strict' class UserChangeAvatar { get rules() { return { avatar: 'required|file|file_ext:png,jpg,jpeg,svg' } } } module.exports = UserChangeAvatar Nothing works, the code lets you upload any

Lookup class method returns empty object instead of user data

这一生的挚爱 提交于 2019-12-13 00:13:06
问题 So, I am creating different helpers to reduce some code on my controller. So I created a class called Lookup to help me search for users in my database and I created a searchAccountKey(key, callback). So, whenever I utilize this method it seems to work however the user object returns with nothing instead of the user. I am suspecting this is happening because of yield but when I do use yield it gives me an error. LookupHelper.js 'use strict'; const User = use('App/Model/User'); class

How to call a generator (async) function on an interval basis

吃可爱长大的小学妹 提交于 2019-12-11 06:09:14
问题 I am building an app that must poll remote devices (generator fn sendRequests() ) every 2 seconds. What's the right way to call the generator fn using setInterval, which isn't a generator and doesn't yield function * sendRequests() { // multiple remote async requests are sent } var timer = setInterval(() => { // yield sendRequests() }, 2000) 回答1: Since AdonisJS uses co() under the hood, I used @Bergi suggestion of wrapping in co() function * sendRequests() { // multiple remote async requests

AdonisJS Error Code “EBADCSRFTOKEN” in Postman in PUT,POST,DELETE operation

倖福魔咒の 提交于 2019-12-10 10:36:12
问题 I have created REST API in AdoniJs. In this I have created API endpoints for CRUD operations with GET, POST, PUT and DELETE menthods. I am using shieldjs as a middleware to verify CSRF token. I am making API calls from Postman. Firstly I am calling GET method of API and I am getting the expected data properly and 3 cookies as part of response, out of which, one is XSRF-TOKEN . But when I am calling PUT, POST and DELETE methods by setting key X-XSRF-TOKEN to the value of XSRF-TOKEN from the