generated from agiledev-students-fall2023/generic-project-repository
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from agiledev-students-fall2023/AddDynamicBorder
add front end and back end for dynamic historical borderline
- Loading branch information
Showing
25 changed files
with
722 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import mongoose from 'mongoose'; | ||
const { Schema, model } = mongoose; | ||
|
||
const FeatureSchema = new Schema({ | ||
type: { type: String, required: true }, | ||
properties: { | ||
NAME: String, | ||
ABBREVN: String, | ||
INFO_UR: String, | ||
SUBJECTO: String, | ||
BORDERPRECISION: Number, | ||
PARTOF: String, | ||
}, | ||
geometry: { | ||
type: { type: String, required: true }, | ||
coordinates: [[[Number]]] | ||
} | ||
}); | ||
|
||
const BorderSchema = new Schema({ | ||
_id: Schema.Types.ObjectId, | ||
type: { type: String, required: true }, | ||
name: { type: String, required: true }, | ||
crs: { | ||
type: { type: String, required: true }, | ||
properties: { | ||
name: { type: String, required: true } | ||
} | ||
}, | ||
features: [FeatureSchema] | ||
}); | ||
|
||
const Border = model('Border', BorderSchema, 'borders'); | ||
|
||
export default Border; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import axios from "axios"; | ||
|
||
const axiosMongoDB = axios.create({ | ||
baseURL: process.env.MONGODB_DATA_API, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'api-key': process.env.MONGODB_API_KEY | ||
} | ||
}); | ||
|
||
export const getBorderData = async (req, res) => { | ||
try { | ||
const name = req.query.name; | ||
console.log(name); | ||
|
||
// Make a request to the MongoDB Data API | ||
const response = await axiosMongoDB.post('/action/find', { | ||
collection: 'borderData', | ||
database: 'bakerdb', | ||
dataSource: 'bakerdb', | ||
filter: { | ||
name: name | ||
} | ||
}); | ||
|
||
if (response.data.documents) { | ||
let data = response.data.documents[0]; | ||
console.log(data) | ||
|
||
res.json(data); | ||
|
||
} else { | ||
res.status(404).send('Data not found'); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
res.status(500).send('Server error'); | ||
} | ||
}; | ||
|
||
export default getBorderData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.