Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add everything for review #1

Open
wants to merge 1 commit into
base: delete-everything
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added brewlette-backend/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions brewlette-backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
.env
71 changes: 71 additions & 0 deletions brewlette-backend/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const express = require("express");
const cors = require("cors");
const app = express();
const axios = require("axios");
require("dotenv").config();
const api = process.env.GOOGLE_API;
app.use(cors());
app.use(express.json());

app.get("/", (req, res) => {
res.send("Hello, this is your Node.js server!");
});
jtkabenni marked this conversation as resolved.
Show resolved Hide resolved

app.get("/api/coordinates", async (req, res) => {
const { address } = req.query;
try {
const apiUrl = "https://maps.googleapis.com/maps/api/geocode/json";
const response = await axios.get(apiUrl, {
params: {
address: address,
key: api,
},
});

return res.json(response.data);
} catch (e) {
console.error(e);
}
});
jtkabenni marked this conversation as resolved.
Show resolved Hide resolved

app.get("/api/google-maps", async (req, res) => {
const { type, radius, location } = req.query;
try {
const apiUrl =
"https://maps.googleapis.com/maps/api/place/nearbysearch/json";
const response = await axios.get(apiUrl, {
params: {
key: api,
type: type,
radius: radius,
location: location,
},
});

return res.json(response.data);
// return res.json(response);
} catch (error) {
console.error(error);
res.status(500).json({ error: "Internal Server Error" });
}
});

app.get("/api/cafe", async (req, res) => {
try {
const apiUrl = "https://maps.googleapis.com/maps/api/place/details/json";
const response = await axios.get(apiUrl, {
params: {
key: api,
place_id: req.query.place_id,
},
});

return res.json(response.data);
// return res.json(response);
} catch (error) {
console.error(error);
res.status(500).json({ error: "Internal Server Error" });
}
});

module.exports = app;
Loading