adonisjs / legacy-docs Goto Github PK
View Code? Open in Web Editor NEWπ The official documentation of AdonisJs
π The official documentation of AdonisJs
How to contribute translation?
It looks like controllers aren't well documented in the v4 API documentation
In the model relationship section, it reads as if when you add a new relationship, the model's operations will continue to automatically. It isn't clear that you need to create the appropriate migrations.
Also, it's important to explain what Lucid relationships do for you so that you can know what migration to create.
For example, for this relationship:
owner {
return this.belongsTo('App/Model/User')
}
I'd expect to add the following migration:
table.string('owner').references('id').inTable('users')
Whereas from looking at example code, this is what is done:
table.integer('user_id').references('id').inTable('users')
I've been using adonis-rally
to help bring everything together, but I'd be great to see a full explanation or tutorial of how everything works together, especially for something as crucial as relationships/migrations. Thanks!
There's info on how to make your own ace commands, however I'm not seeing anything that goes into more depth about the default commands. What are the options for the commands?
landan@lj-desktop:~/www/adonuxt_test$ node ace -V
1.0.0
landan@lj-desktop:~/www/adonuxt_test$ node ace -h
Usage: ace [options] [command]
Commands:
greet <name> Greet a user with a name
nuxtbuild Build for production the nuxt.js application.
auth:setup Setup migrations and models for authentication
repl Start a new repl session when goodness of Es6 generators
make:controller [options] <name> Create a new controller
route:list List all Routes registered for this app
make:migration [options] <name> Create a new migration file
make:model [options] <name> Create a new model with optional migration
make:view [options] <name> Create a new template view by optionally extending a master view
make:command <name> Create a new ace command
make:hook [options] <name> Create a new hook for your models
make:middleware [options] <name> Create a new middleware for Http requests
make:seed <name> Create a new seeder
make:listener [options] <name> Create a new listener for your events
migration:run [options] Run all pending migrations and optionally seed database
migration:rollback [options] Rollback migrations to a given or last batch
migration:refresh [options] Refresh migrations by dropping and re-running all migrations
migration:reset [options] Reset migrations to latest batch
db:seed [options] Seeds database by running all or a given seed file
migration:status Check migrations current status
key:generate [options] Generate encryption key for your application
Options:
-h, --help output usage information
-V, --version output the version number
landan@lj-desktop:~/www/adonuxt_test$
Hello, I propose a new adonis installation section for those who don't want global adonis binary:
prerequisites: npx
npx @adonisjs/cli new yarnstick
cd yarnstick
npm install -save-dev @adonisjs/cli # possibly to be integrated in the blueprints
npx adonis serve --dev
I also suggest adding a --local
flag to the new
command of adonis that would add the npm install --save-dev @adonisjs/cli
command to the installation process
And modify in the end message adonis serve --dev
by npx adonis serve --dev
how I could help in translate?
In chrome 59, the .overlay
div causes a repaint when scrolling, also it has an invalid transform
value which looks like it should be transition
instead.
.overlay {
background: rgba(0,0,0,.4);
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
opacity: 0;
pointer-events: none;
- transform: opacity .2s linear;
+ transition: opacity .2s linear;
+ will-change: transform, opacity;
}
http://dev.adonisjs.com/docs/4.0/database-basics
await ('Database').table('blog_posts').insert({ title: 'Adonis 101', body: 'some description' })
in repo already fixed use
:
await use('Database').table('blog_posts').insert({ title: 'Adonis 101', body: 'some description' })
Cant find where mentioned, but when you follow your http://adonisjs.com/docs/2.0/mail doc, it complains about { [Error: Cannot find module 'got'] code: 'MODULE_NOT_FOUND' }
Of course installing got
fixes the issue, but may want to note it in doc ??
In the docs you have yield Mail.send('emails/welcome', function (message) {
but when I do that, I get callback must be a function
error, because it is expecting the callback to be the 3rd paramaters, not the second.
* send (view, data, callback, config) {
Not sure what data (view merge fields?). I just put yield Mail.send('emails/test', '', function(message) {
as a test and it worked.
First time i needed so hard in docs 'arrow up' on site :) Need it for easy return on start document.
Please. Thx in advance.
Hi,
Just noticed this and saving it for a pull request later. faker.email and everything following should be fake.email() ....
const Factory = use('Factory')
Factory.blueprint('App/Model/User', (fake) => {
return {
username: fake.username(),
email: faker.email(),
password: faker.password(),
firstName: faker.first(),
lastName: faker.last()
}
})
Looking for a way to serve my vue dist directory as the wildcard route, I came across this post:
https://forum.adonisjs.com/t/vue-js-spa-within-adonis-js/363/3
I would be nice to have an example like this (as in the post):
const Helpers = use(βHelpersβ)
Route.any('*', ({response}) => response.download(Helpers.publicPath('main.html')))
This fits for the main ways of creating react and vue front end apps, with create-react-app and vue-cli respectively.
In the Mail docs, Mail.raw
says that it takes three arguments, but it doesn't appear that raw
takes a data argument. Only a string and a callback.
Thanks!
I'd love to see how to add custom Providers. Is there any plan to write docs for this?
Thank you!
I am attempting to add multiple middleware (['auth', 'admin']
) to a route resource that looks something like this:
Route.group('api', () => {
Route
.resource('parent/child', 'ChildController')
.apiOnly()
}).prefix('api/v2')
The middleware should only apply to store
, update
and delete
methods - the index
and show
methods are to be publicly available. In the documentation for Resource Middleware (http://dev.adonisjs.com/docs/4.0/routing#_resource_middleware) it has the following snippet which is meant to solve this problem:
Route
.resource('users', 'UsersController')
.middleware(new Map([
['auth']: ['users.store', 'users.update', 'users.delete']
]))
Unfortunately this is not syntactically correct as an Array
of Array
s should be comma separated. It also throws an Unexpected token :
error when trying to run using adonis serve --dev
. I have tried a variety of ways to get this to work such as the following:
Route
.resource('parent/child', 'ChildController')
.apiOnly()
.middleware(new Map([
['auth', 'admin'], ['parent/child.store', 'parent/child.update', 'parent/child.delete'],
]))
Unfortunately none of the ways I have tried appear to work.
Obviously I can get around this for the time being by simply listing out all my route methods and attaching the middleware to them individually but I would prefer to be able to do it similar to how it is suggested in the documentation.
Reference of v3.2 here
http://adonisjs.com/docs/3.2/validator#_unique_tablename_fieldname
http://adonisjs.com/docs/3.2/validator#_extending_validator
Is v4 different with v3?
Issue make from https://forum.adonisjs.com/t/config-set-method/479
Need to be specified in the docs:
In a many 2 many relationship you have to create a migration for the pivot table too.
I recently started with adonis, and the first thing I wanted to do was get some kind of social authentication going, and there were a few pain points that took me a while to solve and I think would be valuable additions to the social auth docs.
I think it would be useful to go over specifically what you need to setup your database to handle user authentication. A basic review covering just the barebones users migration and user model (noting it can be empty and still work). I feel like the docs are lacking in this regard, repetition isn't used as much as it could to improve understanding.
Add in the common use case of an already-logged-in guard to the "basic example", something like this:
try {
await auth.check()
} catch (error) {
await auth.login(user)
}
async show({ auth, params }) {
try {
let user = await auth.getUser()
return { status: true, data: user }
} catch (e) {
return { status: false, data: 'Not Logged In' }
}
}
Add a note about the session config option sameSite
. I don't know if this is a consistent issue, but using google auth I had a huge issues and I had no idea about this until I found an obscure issue regarding it.
Add an example about the remember(true)
setting, because it seems to need a token model and migration setup with the user. I still haven't figured out how to set this up, though I didn't need it that badly.
Hi,
Thanks for this Node.js MVC Framework. I am very glad I found.
http://www.adonisjs.com/docs/3.0/seeds-and-factories
const users = Factory.model('App/Model/User').create(5)
users.each(function * (user) {
const post = Factory.model('App/Model/Post').make()
yield user.posts().save(post);
})
=> TypeError: users.each is not a function
When I change by
const users = Factory.model('App/Model/User').create(5)
for (var user of users){
const post = Factory.model('App/Model/Post').make()
yield user.posts().save(post );
}
=> TypeError: user.posts is not a function
With post model
'use strict'
const Lucid = use('Lucid')
class User extends Lucid {
posts() {
return this.hasMany('App/Model/Post')
}
}
module.exports = User
any ideas ?
Cheers,
@navdeepsingh commented on Wed Oct 05 2016
Ref: http://www.adonisjs.com/docs/3.0/relationships
@thetutlage commented on Thu Oct 06 2016
Thanks, will fix it π
Hey @thetutlage, any reason why the docs I created don't show on the site? Or am i missing something?
Hi,
In the documentation on the adonisjs.com site at version 4.1 it is not clear where to put the global code.
At the Extending Views section the following is written:
Since the code to extend the View needs to be executed once, you can make use of providers or ignitor hooks. Make sure to read how to extend guide before continuing.
but the link is pointing to the Views page when expected to point to the extend guide.
Thanks.
This is the same issue as here: adonisjs/core#809
Had to view v3.2 docs to see which response methods were available. More specifically, how to return a response with a 400 status code for when Validation fails. Any reason why these aren't there anymore?
Response methods: https://adonisjs.com/docs/3.2/response#_response_methods
Maybe we could adapt this https://github.com/zeke/standard-markdown
tried in my android + desktop browser with narrow window. No action on choosing topic.
Issue make from https://forum.adonisjs.com/t/antl-view-with-user-locale/462/6
It was not clear to me that the redis config for the redis session driver needs to go in config.session.redis
. I was putting it in config.redis
as per the redis docs.
http://dev.adonisjs.com/docs/4.0/routing
#Route parameters
HOW would you handle more than one parameter?
Just look it up under Laravel's Documentation - Got it!
https://laracasts.com/discuss/channels/general-discussion/multiple-optional-route-parameters-to-make-up-date
https://adonisjs.com/docs contain docs till v3.2.
So, where are the docs for v4.0 located?
http://adonisjs.com/docs/3.2/request#_content_negotiation
The Code example should be const type = request.accepts('json', 'html')
The accepts is missing the 's'
Should we add some docs on on view presenters? It is a pretty useful thing that is not well documented at the moment.
There are various typos in some sections of the docs at Adonis Docs.
I wouldn't mind correcting the typos.
Hello guys, first a big thanks for your hard work ! trully a marvellous tool you have build there.
There is a small error in the doc in the ws cluster section
you said to require
require('@adonisjs/websocket-client/clusterPubSub')()
but it should be
require('@adonisjs/websocket/clusterPubSub')()
Am i wrong ?
I noticed everything else is prefixed with adonis-
, which definitely helps when sorting out my forks :)
In version 4.0 softDeletes is no loger exist
But in upgrading page in the docs it not mention
The "managing frontend assets" recipe contains config that is incompatible with the latest webpack 4. I already created a pull request with a fix that explicitly downloads webpack 3 instead of webpack 4, but I think that eventually, the guide should use the latest webpack.
The lucid.fill
and lucid.merge
methods has almost zero or misleading docs. Make sure to update them properly.
Similar to the behaviour of https://vuejs.org/v2/guide/ , a side scrollbar independent of the main one would make navigating the docs a lot easier.
at Views ##Basic example page has wrong namespace.
File: docs/04-http-lifecycle/05-views.adoc
below snippet is
const providers = [
'@adonisjs/frameworks/providers/ViewProvider'
]
should be ...
const providers = [
'@adonisjs/framework/providers/ViewProvider'
]
I see a mixed use of UserController and UsersController in the docs, probably depending on time written. I believe the convention is UserController (singular). Might be good to correct it for clarity.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.