-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (39 loc) · 1001 Bytes
/
index.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Require the framework and instantiate it
const fastify = require('fastify')({
logger: true
})
const mongoose = require('mongoose')
const boom = require('boom')
const url = "mongodb://cferreirasuazo:Cristhian24*@ds245387.mlab.com:45387/erik_fashion"
mongoose.connect(url)
.then(() => console.log("Connected to DB"))
.catch(err => console.log(err))
const routes = require("./routes/index")
var seed = require("./tools/seed")
seed()
routes.forEach((route, index) => {
fastify.route(route)
})
// Declare a route
fastify.get('/', async (request, reply) => {
return { hello: 'world' }
})
// Run the server!
const start = async () => {
try {
await fastify.listen(3000)
fastify.log.info(`server listening on ${fastify.server.address().port}`)
} catch (err) {
fastify.log.error(err)
process.exit(1)
}
}
start()
// seed.map(x =>{
// var articulo = new Articulo(x)
// try{
// articulo.save()
// }catch(err){
// console.log(err)
// }
// })