GithubHelp home page GithubHelp logo

adonisjs / v5-docs Goto Github PK

View Code? Open in Web Editor NEW
88.0 9.0 141.0 4.13 MB

📚 Source code and documentation for the official docs website.

Home Page: https://v5-docs.adonisjs.com

TypeScript 38.60% CSS 26.99% JavaScript 10.17% Edge 24.24%
hacktoberfest documentation adonisjs

v5-docs's Issues

beforePaginate hook example throws error

Package version

15.0.1

Node.js and npm version

14.17.0, 6.14.3

Issue

Trying to implement beforePaginate as the suggested solution to adonisjs/lucid#647 using the documented example at (https://docs.adonisjs.com/reference/orm/decorators#beforepaginate)

import { beforePaginate, BaseModel } from '@ioc:Adonis/Lucid/Orm'

class Post extends BaseModel {

  @beforePaginate()
  public static withoutSoftDeletes(query) {
    query.whereNull('deleted_at')
  }

}

returns the following error

query.whereNull is not a function

Explanation for why to pick database vs redis api token storage

Package version

none

Describe the bug

On the API Tokens page it's stated that the database is the best options for secondary auth while redis is best for the main form of auth. This seems fine to me but I think it would be a lot clearer with another line explaining the reason why the database or redis are more suited to the task.

Reproduction repo

No response

Additional Example to Request Validation

Package version

latest

Describe the bug

It took me a bit to validate additional request properties alongside the request body. An example on how to do so would likely save others some time.

Reproduction repo

No response

Ace - decorator flags

Discussed in adonisjs/core#3166

Originally posted by sergefabre September 13, 2021
Hello,
I'm following the example on the docs about the flags.boolean decorator, but the property does not exist with my version of Adonis.
Here is an extract of my package.json file:

"dependencies": {
    "@adonisjs/ally": "^4.1.1",
    "@adonisjs/auth": "^8.0.9",
    "@adonisjs/core": "^5.3.4",
    "@adonisjs/lucid": "^16.0.0",
    "@adonisjs/repl": "^3.1.6",
    "@adonisjs/view": "^6.1.0",

Here is the problem in my IDE (VS Code):
image
Telling me that default does not exist in the type Partial<Omit<CommandFlag, "type" | "propertyName">>.

I don't know if I'm doing something wrong, or if the docs are for a more recent or dev version (it doesn't show up in the docs website, you used to be able to do this with the legacy docs).

`this.defer` does't work as expected in migrations

I'm creating a dictionary table. Immediately after creation, it must be filled with certain static data. I take an example from the documentation, but it doesn't work:

this.defer(async (db) => {
      const users = await db.select('*').from('users') // TS2339: Property 'select' does not exist on type 'QueryClientContract'.
      await Promise.all(users.map((user) => {
        return db
          .table('user_emails')
          .insert({ user_id: user.id, email: user.email })
      }))
    })

And runtime error:

[ error ]  db.select is not a function

Package version

"@adonisjs/core": "5.7.5",
"@adonisjs/lucid": "17.2.0",

Node.js and npm version

8.3.1

Cloudflare Email Address Obfuscation false positive

On the installation page, Cloudflare replaces

npm init adonis-ts-app@latest hello-world

with:

npm init [email protected] hello-world

This can be fixed by disabling thee Cloudflare's Email Address Obfuscation feature.

[official doc bug] Testing upload image example seems out of date

Official spec example from here link seems not to work,

running version : "@adonisjs/core": "^5.6.0"

it dose not have file.createPng('1mb') method and fakeDrive.hasFile() method,
and if follow the import { file } from '@ioc:Adonis/Core/Helpers'
it can get a new file.generatePng() method there, but as the same time .file('avatar', fakeAvatar) will get fail because of the type error

hoping the team can update the new doc to help people get into the adonis more easily.

Limiter documentation issue

Package version

latest

Describe the bug

The docs mention in-memory store for the rate limiter, however, this isn't true as it doesn't exist in the application.

image

Reproduction repo

No response

Documentation on Dockerizing AdonisJS incomplete

Package version

n/a

Describe the bug

The documentation for /Cookbooks/dockerize-adonis/ is incomplete by omitting what to do about the APP_KEY value. Following the instructions verbatim, and copy/pasting the config files here verbatim will result in the following output in the container's log.

2023-08-29 14:10:18 Exception: E_MISSING_ENV_VALUE: Missing environment variable "APP_KEY"
2023-08-29 14:10:18     at ensureValue (/home/node/app/node_modules/@adonisjs/env/build/src/Schema/helpers.js:26:15)
2023-08-29 14:10:18     at Object.validate [as APP_KEY] (/home/node/app/node_modules/@adonisjs/env/build/src/Schema/string.js:45:35)
2023-08-29 14:10:18     at /home/node/app/node_modules/@adonisjs/env/build/src/Env/index.js:87:60
2023-08-29 14:10:18     at Array.forEach (<anonymous>)
2023-08-29 14:10:18     at Env.process (/home/node/app/node_modules/@adonisjs/env/build/src/Env/index.js:86:44)
2023-08-29 14:10:18     at Application.loadEnvironmentVariables (/home/node/app/node_modules/@adonisjs/application/build/src/Application.js:303:18)
2023-08-29 14:10:18     at Application.setup (/home/node/app/node_modules/@adonisjs/application/build/src/Application.js:518:14)
2023-08-29 14:10:18     at AppKernel.boot (/home/node/app/node_modules/@adonisjs/core/build/src/Ignitor/Kernel/index.js:55:32)
2023-08-29 14:10:18     at HttpServer.start (/home/node/app/node_modules/@adonisjs/core/build/src/Ignitor/HttpServer/index.js:85:31)
2023-08-29 14:10:18     at Object.<anonymous> (/home/node/server.ts:21:4)
2023-08-29 14:11:34 {"level":30,"time":1693332694392,"pid":8,"hostname":"4cbf60af4c7b","name":"my-project-api","msg":"started server on 0.0.0.0:3333"}

The APP_KEY value is never mentioned in this guide.

Reproduction repo

No response

mysql bigint

Our vendor databases use bigint as the primary key which is rather annoying.

Out of the box lucid (mysql driver) doesn't appear to support it.

After a few hours of trying to find a solution there is a setting that can be enabled to support this.

connections: {
    mysql: {
      client: 'mysql',
      connection: {
        host: Env.get('MYSQL_HOST'),
        port: Env.get('MYSQL_PORT'),
        user: Env.get('MYSQL_USER'),
        password: Env.get('MYSQL_PASSWORD', ''),
        database: Env.get('MYSQL_DB_NAME'),
        supportBigNumbers: true, // <---- here
      },
      migrations: {
        naturalSort: true,
      },
      healthCheck: false,
      debug: false,
    },
  }

Can you please add this to the documentation regarding supportBigNumbers: true as it would save a lot of headaches.

Thanks

Wrong documentation for database driver config

Package version

5.8.4

Describe the bug

Link of documentation: https://docs.adonisjs.com/guides/database/introduction#drivers-config

The documentation guides us to install the package mysql2 but in the config example the client used is mysql. After I changed it to mysql2 the config started to work.

Also, the code generated by node ace configure @adonisjs/lucid generates a file with a comment that instructs to install mysql instead of mysql2.

Reproduction repo

No response

Query Scopes Documentation

Documentation of Query Scopes - https://docs.adonisjs.com/guides/models/query-scopes appears to be incorrect.

The ModelQueryBuilderContract does not appear to have a function called withScopes, after looking through the tests, it appears it should be apply

e.g.

Post
    .query()
    .withScopes((scopes) => scopes.published())

should be

Post
    .query()
    .apply((scopes) => scopes.published())

It is correct in the reference page - https://docs.adonisjs.com/reference/orm/query-builder#apply

Improve type information at Wildcard

Documentation for Custom messages with wildcard callback is missing types for it's parameters.

I've assumed types are correct at MessageBag.

Change proposal on the code example

const wildCardError = (
  field: string,
  rule: string,
  arrayExpressionPointer?: string,
  options?: any
) => {
  return `${rule} validation error on ${field}`
}

{
  messages: {
    '*': wildCardError,
    'username.required': 'Username is required to sign up',
  }
}

AdonisJS webpack-encore DELETED my assets files

adonisjs-error

why my assets files always deleted by webpack-encore while compiling (npm run dev) like on the pic, while creating the adonisjs project I choose "true" for configure webpack-encore. I newbie at webpack or something like that, please help me I'm so stuck here. thanks for the answer and I appreciate it. 😄😄

Global transactions documentation missing `await` keyword

In the global transactions documentation, I think the cleanup function should be an async function and should have the await keyword.

Currently, it is return () => Database.rollbackGlobalTransaction(), I think it should be: return async () => await Database.rollbackGlobalTransaction(), since the rollbackGlobalTransaction() function returns a promise.

I can open a PR, just wanted to make sure this wasn't intentional.

Portuguese Translation

Translating process

How to start?

First thing you should do is reply to this issue picking one of the following topics that have 💤. After that go to this repo and fork it. Create a branch with the name of the topic you pick and start translating each subsection.

How do i merge my translation?

After you finish the translation of your topic, submit a PR on the branch pt-translation-merging. Other translator should check your translation for misspelling and translating conventions.

Can i review other people PR?

Absolutely. Please look at our Translation conventions table in the end of this issue

The topic that i choose is too big, how to get help?

It's essentialy the same process. Have someone fork your repo, create a branch with the subtopic translation, and submit to your topic branch as a PR. You can review his PR and get all the help you need. You can use this issue to call for help.

How do you control the stages of a Topic?

💤 No fork :zzz:
✍🏼 forked :writing_hand:
👀 fork under review :eyes:
📗 translation merged :green_book:


Guides

📗 introduction-installation-release
✍️ Fundamentals @guntribam/Fundamentals
💤 Http
💤 Views & Templates
💤 Validator
💤 Database
💤 ORM
💤 Authentication
💤 Security
💤 Digging deeper

Reference

Database

💤 First Section(Connection, Connection manager, etc)
💤 ORM
💤 Relationships

Validator

💤 Schema types
💤 Validation rules

Views & Templates

💤 Globals
💤 Tags

Cookbooks

💤 Using socket.io
💤 Writing tests
💤 Deployment
💤 Validator

Releases

💤 Out of preview
💤 December release -2020
💤 October release -2020
💤 August release -2020
💤 Introducing AdonisJS V5 Preview


Translation conventions

English Portuguese
breaking changes - mudanças não retrocompatíveis
- quebras de código
framework framework
build construção
release - lançamento
- liberação

Documentation about IOC Container

Hi. I was trying the other day to use the new version of the framework to achieve something like Spring Boot does in Java with with it's IOC Container, and I noticed that website lacks a little more information about this. I wanted to write something like:

export default interface FooRepositoryInterface {
  findAll(): Promise<Foo>
}
export default class FooRepository implements FooRepositoryInterface{
  findAll(): Promise<Foo> {
    // Implementation
  }
}
export default interface FooServiceInterface {
  list(): Promise<Foo>
}
export default class FooService implements FooServiceInterface {

  constructor(public FooRepositoryInterface repository) {}

  list(): Promise<Foo> {
    return repository.findAll()
  }
}
export default class FooController {

  constructor(public FooServiceInterface service) {}

  index() {
    service.list()
  }
}

It is possible to achieve this kind of behavior with the current version of the framework? If it is, could you guys provide me some examples or guides in how to register the dependencies on the IOC container correctly? I tried to register the classes on the provider but I could achieve the result I wanted.
Thanks in advance.

Documentation includes features that haven't been released yet.

Package version

N/A

Describe the bug

As a developer, I would expect the documentation on "docs.adonisjs.com" to reflect what is currently possible, and not documentation for features that have yet to be released.

For instance, this is currently not possible:
https://docs.adonisjs.com/guides/testing/introduction#truncate-database-after-each-run-cycle

It wasn't until after updating Adonis and searching around did I figure out that it's still a feature sitting in the develop branch of adonisjs/lucid, and not something that is currently available to me.

Just thought I'd throw this out there, in the hopes that this is taken into consideration in the future, for a better developer experience. I'm also not sure if this something is already being considered and this slipped by, or if there's just no formal process for ensuring that the feature is available before it lands on the docs.

Reproduction repo

No response

AdonisJS Community Translations

Please notify us about the translation you are maintaining and the associated repo. Also make sure to subscribe to this issue to receive documentation updates notifications

Driver config: mysql2

On the documentation it says to install the following

npm i mysql2

but it says to use it

mysql: {
  client: 'mysql',
  connection: {
    host: Env.get('MYSQL_HOST'),
    port: Env.get('MYSQL_PORT'),
    user: Env.get('MYSQL_USER'),
    password: Env.get('MYSQL_PASSWORD', ''),
    database: Env.get('MYSQL_DB_NAME'),
  },
  migrations: {
    naturalSort: true,
  },
  healthCheck: false,
  debug: false,
}

i am not quite sure if this is a bug or its supposed to work that way, i changed the client: 'mysql' to 'mysql2' and it worked, could you confirm?
this should solve mysql 8.* issues

Drive documentation references both `serveAssets` and `serveFiles`

Package version

latest

Describe the bug

Drive documentation seems to reference a config variable called serveAssets and serveFiles interchangeably. In my code, it's defaulted to serveFiles so it seems like the serveAssets may be incorrect.

image

Reproduction repo

No response

Typo in adonis at a glance page

the sentence As per the standards today, the CSS and the frontend JavaScript need to transpiled and minified before serving it to the browser is missing the be before transpiled

Docker compose volume issue

I noticed that whenever im working on macOS the docker-compose, argon2 and bcrypt issues arise
turned out

volumes:
     - ./:/home/node/app

is linking the container to the node_modules on the host so

     - /home/node/app/node_modules

adding this will exclude the node_modules usage from host, and creates an anonymous volume that holds the node_modules, thought it solves the issue, what its doing actually is creating a new "node_modules" which means we end up with 3 places with node_modules, not a very pretty solution,

Sadly this solution needs an image rebuild each time the package.json is updated

Reference:
https://burnedikt.com/dockerized-node-development-and-mounting-node-volumes/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.