{"size": 819, "ext": "js", "max_stars_repo_path": "server.js", "max_stars_repo_name": "Joey393d/can-of-books-backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server.js", "max_issues_repo_name": "Joey393d/can-of-books-backend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server.js", "max_forks_repo_name": "Joey393d/can-of-books-backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 16.0588235294, "max_line_length": 77, "alphanum_fraction": 0.6568986569}
'use strict';


const express = require('express');
require('dotenv').config();
const cors = require('cors');


const mongoose = require('mongoose');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
  console.log('mongo is now connected!');
});


mongoose.connect(process.env.MONGODB_URL);


const Book = require('./models/book');

const app = express();


app.use(cors());


app.get('/books', async (req, res) => {
  const location = req.query.location;

  const findQuery = {};
  
  const books = await Book.find(findQuery);

  res.send(books);

  console.log(books);
})




const PORT = process.env.PORT || 3001;



if (!parseInt(PORT)) throw 'Invalid PORT';


app.listen(PORT, () => console.log(`listening on http://localhost:${PORT}`));
