{"size": 1188, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "echohatch1/Landon_crud_server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "echohatch1/Landon_crud_server", "max_issues_repo_issues_event_min_datetime": "2021-05-08T04:05:59.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T03:43:45.000Z", "max_forks_repo_path": "index.js", "max_forks_repo_name": "echohatch1/Landon_crud_server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 33.9428571429, "max_line_length": 98, "alphanum_fraction": 0.7247474747}
const express = require('express')
const bodyParser = require('body-parser')
const mongoose = require('mongoose')

// set up the mongoose to Atlas connection
const dev_db_url = 'mongodb+srv://someuser:abcd1234@product-cluster-opg2q.gcp.mongodb.net/product'
const mongoDB = process.env.MONGODB_URI || dev_db_url
mongoose.connect(mongoDB, {useNewUrlParser: true})
mongoose.Promise = global.Promise
const db = mongoose.connection
db.on('error', console.error.bind(console, 'MongoDB connection error:'))

const product = require('./routes/product.route')// imports routes for the products
const pokemon = require('./routes/pokemon.route')

const app = express()

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))

app.use('/products', product)
app.use('/pokemon', pokemon)

app.use((req, res, next) => {
    res.setHeader('Access-Control-Allow-Origin', '*')
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE')
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization')
    next()
})

const port = (process.env.PORT || 5000)

app.listen(port, () => {
    console.log(`Server is up and running on port ${port}`)
})