Questions tagged [adonis.js]

Adonis is a full stack, open source MVC framework for Node.js. The framework is inspired by the PHP framework Laravel.

AdonisJs is an MVC Framework for Node.js.

It includes:

  • Lucid ORM
  • Database Migrations
  • Authentication System
  • OAuth
  • Mailing System
  • Data Validator
  • Testing

Learn more on the website and check out the organization on Github.

739 questions
2
votes
2 answers

Multiple primary keys in table using adonis migration / nodejs

I have this table: BookUnit ------------------- id PK unit PK sequence PK book_id FK So, i can have records with data: id: 1 unit: 1 sequence: 1 id: 2 unit: 1 sequence: 2 but i can't have more than one repetead: id: 3 unit: 1 sequence: 2 So, i…
bla
  • 995
  • 3
  • 11
  • 44
2
votes
2 answers

Relation does not exist in adonis/node.js

I have two tables: book and book_units as you can see below: class BookSchema extends Schema { up () { this.create('books', (table) => { table.increments() table.string('code').notNullable().unique() …
bla
  • 995
  • 3
  • 11
  • 44
2
votes
1 answer

There's a way to export the result of the unit test in visual studio code?

I have this test in adonis.js - node.js: test('realiza login com o usuário registrado', async ({ client }) => { const response = await client .post('login') .send({ username: 'usuarioteste', password: 'usuarioteste' }) …
bla
  • 995
  • 3
  • 11
  • 44
2
votes
1 answer

Unsure how to save to database with foreign key in AdonisJs

Summary I'm creating a photography app to help photographers keep track of their clients. This is my first project using Adonis.JS and I really enjoy it so far, but been stuck on this problem for a while and can't find an answer anywhere. I'll share…
2
votes
1 answer

How to return a 401 error with Adonis' websocket middleware

I’m building a websocket middleware and I want to return a 401 from it. This is my code: async wsHandle({ request, response }, next) { let token =request.only('token').token; await axios.get('auth server url', { headers: { …
Rick
  • 21
  • 3
2
votes
1 answer

AdonisJS Error Code "EBADCSRFTOKEN" in Postman in PUT,POST,DELETE operation

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…
Kumar Sanu
  • 206
  • 2
  • 12
2
votes
1 answer

Adonis js How to reorder of creation of tables schema for migration to mysql

Problem is at the time of migration my child tables created at first and it could not find parents table and not able to assign the foreign key of parent table primary key and i get the error as below. here warehouses is children and the companies…
paras shah
  • 861
  • 2
  • 9
  • 23
2
votes
1 answer

Change HTML tag based on results from database in Adonis.js

I am building a node.js app using Adonis and depending on what one of the columns returned in my query is change how the html is done. If the row has a 'Y' in the Group column I need to display it as an

otherwise it needs to be displayed as a…

John Carty
  • 242
  • 2
  • 13
2
votes
1 answer

How to validate multipart file on AdonisJS?

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…
Yung Silva
  • 1,324
  • 4
  • 20
  • 40
2
votes
0 answers

How to fix 'invalid JSON, only supports object and array' in AdonisJS?

I am using Adonisjs v5 and Angular 7. When I tried to upload file with formData from frontend then it throws the error error: invalid JSON, only supports object and array I believe it is bodyParse error, but I have not been able to resolve…
tts
  • 157
  • 1
  • 1
  • 13
2
votes
0 answers

Is it normal that it takes 3 minutes to restart nodemon due to changes?

It takes more than 3 min to restart nodemon. I think it is too long. I use adonisjs + nuxt (from https://github.com/nuxt/create-nuxt-app). Under dev mode(I ran "npm run dev"), I have some server side files that is controllers or models(red area in…
Lawyer Kenny
  • 363
  • 4
  • 16
2
votes
2 answers

Adonis js Edge get domain url in assetUrl

Am sending an email via adonis mailer and i would like to get the domain name to include in the images on the edge files but am stuck on how to add the domain name as emails sent dont display the images So in my email edge file i have …
Geoff
  • 6,277
  • 23
  • 87
  • 197
2
votes
1 answer

Use Query Builder inside computed property in Adonis JS

I have two models, Contract and TimeEntry. The TimeEntry model has 'hours' as a column and references a Contract through it's 'contract_id' foreign key column. I'd like to return the "total hours" for a contract based on the related time entries,…
Nicholas Harder
  • 1,496
  • 10
  • 15
2
votes
0 answers

how do I hide schema and migration information while running migration in adonisjs test

I am new to adonis JS. I have looked at the docs and other resources but couldn't figure out how to only show the test results without all the migration up and down information. As you can see from image below, the result of test is sandwich between…
Amrit Shrestha
  • 1,620
  • 20
  • 25
2
votes
0 answers

MySQL authentication error with Node and Adonis even after mysql_native_password

I am trying to connect to a MySQL database from a Node JS app running Adonis JS. However, when I try to connect (by loading a page that's routed to a controller that performs a basic SELECT query). I get this error: "Client does not support…
Max Stevens
  • 101
  • 1
  • 7