From cd760f0cf83cb00b9c4b372ed1b6ed5baf1b6272 Mon Sep 17 00:00:00 2001 From: Mhykol Date: Mon, 3 Jun 2024 05:26:09 -0400 Subject: Added error handling for missing directories and examples --- examples/index.js | 21 +++++++++++++++++++++ examples/shop.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 examples/index.js create mode 100644 examples/shop.js (limited to 'examples') diff --git a/examples/index.js b/examples/index.js new file mode 100644 index 0000000..64a619b --- /dev/null +++ b/examples/index.js @@ -0,0 +1,21 @@ +class Index { + constructor() {} + + async Main() { + return { + html: ` +
+

Welcome to Cosmic!

+

Please read the README.md

+
+ `, + meta: { + keywords: 'Cosmic', + description: 'Welcome to Cosmic!' + } + } + } +} + +module.exports = (x) => {return new Index(x)} + diff --git a/examples/shop.js b/examples/shop.js new file mode 100644 index 0000000..e75d289 --- /dev/null +++ b/examples/shop.js @@ -0,0 +1,51 @@ +const database = require('../source/database') +const estore = database('EStore') + +class Shop { + constructor() {} + + async Main() { + return estore.Query('SELECT * FROM Products').then(output => { + const data = { + start: ` +
+
+

This is the Shop page

+ `, + body: '', + end: ` +
+
+ ` + } + if (output) { + for (let i = 0; i < output[0].length; i++) { + data.body += ` +
+

${output[0][i].ProductName}

+

ID: ${output[0][i].ID}

+
+ ` + } + } else { + data.body = ` + There are no items in the database. + ` + } + return data.start + data.body + data.end + }) + } + Product() { + const data = ` +
+
+

This is the Product page

+

Description

+
+
+ ` + return data + } +} + +module.exports = () => {return new Shop()} -- cgit v1.2.3-70-g09d2