-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (26 loc) · 759 Bytes
/
Copy pathindex.js
File metadata and controls
35 lines (26 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const {sequelize, Store, Products} = require('./src/database')
const {server} = require('./src/app')
const data = require('./src/data/data')
const port = process.env.PORT || 4000
sequelize.sync({ force: true }).then(async() => {
const storeStatus = await Store.findAll();
const info = await Products.findAll();// data de la tabla
if(storeStatus.length === 0){
Store.create({
status: 'offline',
name: 'Hit',
email: 'hitpasta@gmail.com',
password: '1234567'
})
}
if(info.length === 0){
Products.bulkCreate(data) // llena la tabla
}
try {
server.listen(port, () => {
console.log(`%s server is listening on port ${port}`);
});
} catch (error) {
console.log(error)
}
});