The motivation for this project is to learn about Docker, Node.js with SQLite through Sequelize.
- Docker
- Docker-Compose
- npm
- Node.js
- Espress
- Nodemon
- Morgan
- Sequelize
- SQLite3
- Babel
- Consign
GET /users
GET /users/:id
POST /users
PUT /users/:id
DEL /users/:id
GET /address
GET /address/:id
POST /address/:userId
PUT /address/:id
DEL /address/:id
There are two models:
User
{
"name":"Siziksu",
"email":"siziksu@gmail.com",
"age":25
}
Address
{
"name":"Av. Diagonal 604",
"cp":"08006"
}
When a user is requested returns both joined:
User + Address
{
"name":"Siziksu",
"email":"siziksu@gmail.com",
"age":25,
"address": {
"name":"Av. Diagonal 604",
"cp":"08006"
}
}
This process needs
sequelize-cli
installed and theserver/config/config.json
file. This process will create the folderseeders
and inside of it, eachseeder
file.
Note All this process is done inside theserver
folder.
- Go to the
server
folder - To create the
seeds
, run:
$ ./node_modules/.bin/sequelize seed:create --name users-seeder
$ ./node_modules/.bin/sequelize seed:create --name address-seeder
- Edit each seed with the content that you need
- Seed
$ ./node_modules/.bin/sequelize db:seed:all
Copyright 2019 Esteban Latre
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.