Sample page: https://mighty-wave-10606.herokuapp.com/
.env
Please create .env file in reference to .env.sample
database.json
Please create database.json file in reference to database.sample.json
npm install sequelize-cli -g
sequelize db:migrate
or
npx sequelize db:migrate
You can migrate db to use sequelize-cli.
http://docs.sequelizejs.com/manual/migrations.html
# install dependencies
$ npm install
# serve with hot reload at localhost:3000
$ npm run dev
# build for production and launch server
$ npm run build
$ npm start
# generate static project
$ npm run generate
For detailed explanation on how things work, checkout Nuxt.js docs.
Set Debug Nuxt on Chrome
setting and exec(F5)
You can use debugger
and breakpoint and debug your code.
Attention:
- If you use Chrome, you have to install Debugger for Chrome to your VSCode.
- Note that the screen does not appear until build is complete.
You can use REPL mode and check created model.
npm run db:shell
// create user
db.User.create({name: "redshoga"})
// find all user name
db.User.findAll().then(userList => userList.forEach(user => console.log(user.name)))
// create todo
db.User.findOne({name: "redshoga"}).then(user => user.createTodo({'title': 'My first todo'}))
db.User.findOne({name: "redshoga"}).then(user => user.createTodo({'title': 'My second todo'}))
db.User.findOne({name: "redshoga"}).then(user => user.createTodo({'title': 'My third todo'}))
// find all task title
db.Todo.findAll().then(todoList => todoList.forEach(todo => console.log(todo.title)))
// find user's task list
db.User.findOne({name: "redshoga"}).
then(user => user.getTodos()).
then(todoList => todoList.forEach(t => console.log(t.title)))
// delete user
db.User.findOne({name: "redshoga"}).then(user => user.destroy())
// or
// db.User.destroy({where: {name: "redshoga"}})
// All user's task.UserId should be null
db.Todo.findAll().then(todoList => todoList.forEach(todo => console.log(todo.UserId)))
Sample page: https://mighty-wave-10606.herokuapp.com/
- Preparation
npm install -g heroku
heroku plugins:install heroku-config
heroku login
heroku create
heroku addons:create heroku-postgresql:hobby-dev
-
Change production settings database.json for heroku Postgres
-
Exec script to set environment variables to heroku
node set_heroku_config.js
- Deploy
git push heroku master
- Create Nuxt project on Express
- Add passport
- Add sequelize
- Add debug settings on VSCode
- Add Sequelize REPL mode
- Change to TODO Example
- Add sample deployed page link
- Add how to deploy on heroku
- Create cli tool like create-nuxt-app
- Typescript support