Skip to content

Task 6: SQL DATABASES. ORM#6

Open
aleksandra-sturova wants to merge 1 commit intotask-5from
task-6
Open

Task 6: SQL DATABASES. ORM#6
aleksandra-sturova wants to merge 1 commit intotask-5from
task-6

Conversation

@aleksandra-sturova
Copy link
Owner

No description provided.

"babel": "babel src --out-dir dist --copy-files",
"babel:watch": "babel -w src --out-dir dist",
"nodemon": "nodemon ./dist/index.js",
"start": "start npm run babel:watch && start npm run nodemon"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds db:drop, db:create, db:migrate, db.seed:all into one npm's script, please

Why db:drop?
It would be better to make sure that database doesn't exist because in other way it gives to us error message that database is already exist.


app.use(queryParser());
app.use(cookieParser(), setCoockies());
app.use(bodyParser.urlencoded({ extended: true }));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is from Express v4 bodyParser libraty doesn't need because the one already is situated in Express library.

app.use(express.urlencode({ extenred: true }));
app.use(express.json());

} else {
products.push(newProduct);
res.status(201).send(products);
Product.create(newProduct)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds check if product already exist in db, please
Hits: findAndCreate

var Sequelize = require('sequelize');
var basename = path.basename(__filename);
var env = process.env.NODE_ENV || 'development';
var config = require(`${__dirname}/../config/config.json`)[env];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codestyle

"dialect": "postgres"
},
"test": {
"username": "local-postgress-1.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange username for db

"dialect": "postgres"
},
"production": {
"username": "local-postgress-1.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^

if (allowAccess) {
const token = jwt.sign({ userName }, 'secret13', { expiresIn: 30 });
if (allowAccess) {
const token = jwt.sign({ userName }, 'secret13', { expiresIn: 10000 });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export expiresIn into config and env variable, please

@vladislavkovaliov
Copy link

Take a look in advance topic, please
Try using .sequualizerc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants