Adonis

$ npm install -g @adonisjs/cli
$ adonis new --api-only --yarn my-app-name
$ yarn add pg

.env:

DB_CONNECTION=pg
DB_HOST=127.0.0.1
DB_PORT=
DB_USER=postgres
DB_PASSWORD=
DB_DATABASE=my_app_name

Manually create the DB using e.g. Postico

$ adonis make:model Post --migration
$ adonis make:controller Post --resource --type http
$ adonis make:seed Post
table.string('columnName').unique()
table.integer(…).notNullable()
table.foreign('foo_id').references('id').inTable('foos');
table.dropColumn(…)

this.alter('table', table => {…})

PostSeeder.js:

const post = await Post.create({ title, body })

routes.js:

Route.resource('posts', 'PostController')

PostController.js:

return Post.all();
.find(id)
.findBy('field', value)
.query().where({…}).fetch()

post.comments().fetch()
post.comments().create({…})
$ adonis migration:run
$ adonis seed
$ adonis serve --dev (for live reloading)
$ adonis make:test foo
$ adonis test

CORS: in config/cors.js, set origin: true

KEY GUIDES PAGES