On file config/shield.js
at csrf
key default is filterUris: [],
change this to filterUris: [/^\/webhooks\//, /^\/api\/v1/],
at head section add {{ cspMeta() }}
at form add {{ csrfField() }}
Use (@adonisjs/http-logger)[https://github.com/adonisjs/adonis-http-logger]
On file config/database.js
, find your database like mysql
and add another line as debug: true
or debug: Env.get('DB_LOG', false)
and set DB_LOG
value at .env
file
on heroku use ENV_SILENT=true
or
write this code on server.js
if (process.env.CREATE_ENV == '1') {
const fs = require('fs')
try {
if (!fs.existsSync('.env') && fs.existsSync('.env.example')) {
var data = fs.readFileSync('.env.example');
fs.writeFileSync('.env', data);
}
} catch(err) {
console.error(err)
}
}
adonis db:drop
and adonis db:create
follow below code for these cmds
adonis make:command db:create
adonis make:command db:drop
→ Open start/app.js and add below lines into commands
const commands = [
'App/Commands/DbCreate',
'App/Commands/DbDrop'
]
- either use PM2 & nginx for managing the services well. RECOMMENDED
- or you can run by the default OS services. I'm using ubuntu 20.04 amd64 on ec2-t2.micro and everything is preinstall with image.
# TO Run the service on port 80 as deamon thread
sudo PORT=80 nohup node server.js &
#To run the service on 3000 port and point to 80.
PORT=3000 nohup node server.js &
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
# to kill the process run
ps -ef | grep "node"
kill -9 <pid>