-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor openapi.yaml attributes to use consistent
format and fix endpoint summary The openapi.yaml file was modified to refactor the attributes for various endpoints in order to use a consistent format. In particular, the format for UUID-like attributes was changed to match a specific pattern and have a fixed length of 24 characters. Additionally, the summary of the "/models" endpoint was updated to clarify its purpose. These changes improve the consistency and clarity of the API documentation. No issues were referenced in this commit.
- Loading branch information
1 parent
69cadb5
commit 92c63ea
Showing
15 changed files
with
2,996 additions
and
1,407 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
/** | ||
* File: /loadEnviroment.mjs | ||
* Description: | ||
* Used by: | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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,68 @@ | ||
/** | ||
* File: /routers/models.mjs | ||
* Description: | ||
* | ||
* Date By Comments | ||
* ---------- ----- ------------------------------ | ||
* 2023-12-29 C2RLO Initial | ||
**/ | ||
|
||
import express from "express" | ||
import db from "../db/conn.mjs" | ||
import { ObjectId } from "mongodb" | ||
|
||
const router = express.Router() | ||
|
||
// Get all | ||
router.get("/", async (req, res) => { | ||
const collection = await db.collection("models") | ||
const results = await collection.find({}).limit(50).toArray() | ||
res.send(results).status(200) | ||
}) | ||
|
||
// Get a single post | ||
router.get("/:id", async (req, res) => { | ||
const collection = await db.collection("models") | ||
const query = { _id: ObjectId(req.params.id) } | ||
const result = await collection.findOne(query) | ||
if (!result) res.send("Not found").status(404) | ||
else res.send(result).status(200) | ||
}) | ||
|
||
// Create | ||
router.post("/", async (req, res) => { | ||
const collection = await db.collection("models") | ||
const newDocument = req.body | ||
// newDocument.date = new Date() | ||
const results = await collection.insertOne(newDocument) | ||
res.send(results).status(204) | ||
}) | ||
|
||
// Update the device's :id position | ||
router.patch("/position/:id", async (req, res) => { | ||
const query = { _id: ObjectId(req.params.id) } | ||
const updates = { | ||
$push: { position: req.body } | ||
} | ||
const collection = await db.collection("models") | ||
const result = await collection.updateOne(query, updates) | ||
res.send(result).status(200) | ||
}) | ||
|
||
// Delete an entry | ||
router.delete("/:id", async (req, res) => { | ||
const query = { _id: ObjectId(req.params.id) } | ||
const collection = db.collection("models") | ||
const result = await collection.deleteOne(query) | ||
res.send(result).status(200) | ||
}) | ||
|
||
// Delete all | ||
router.delete("/", async (req, res) => { | ||
const query = { } | ||
const collection = db.collection("models") | ||
const result = await collection.deleteMany(query) | ||
res.send(result).status(200) | ||
}) | ||
|
||
export default router |
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.