summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2024-06-03 05:26:09 -0400
committerMhykol <mchaeldonald62@pm.me>2024-06-03 05:26:09 -0400
commitcd760f0cf83cb00b9c4b372ed1b6ed5baf1b6272 (patch)
tree94cf37e9c3dcf017fc65a50b52045856a6100537 /examples
parent3135b036ce787d00228e627d9af58dfd9b5a1b08 (diff)
Added error handling for missing directories and examples
Diffstat (limited to 'examples')
-rw-r--r--examples/index.js21
-rw-r--r--examples/shop.js51
2 files changed, 72 insertions, 0 deletions
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: `
+ <section>
+ <h1>Welcome to <a href='https://git.fatalmatrix.xyz/cosmic.git'>Cosmic</a>!</h1>
+ <p>Please read the README.md</p>
+ </section>
+ `,
+ 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: `
+ <section id='shop'>
+ <div>
+ <h1>This is the Shop page</h1>
+ `,
+ body: '',
+ end: `
+ </div>
+ </section>
+ `
+ }
+ if (output) {
+ for (let i = 0; i < output[0].length; i++) {
+ data.body += `
+ <div class='item'>
+ <h2>${output[0][i].ProductName}</h2>
+ <p>ID: ${output[0][i].ID}</p>
+ </div>
+ `
+ }
+ } else {
+ data.body = `
+ There are no items in the database.
+ `
+ }
+ return data.start + data.body + data.end
+ })
+ }
+ Product() {
+ const data = `
+ <section id='product'>
+ <div>
+ <h1>This is the Product page</h1>
+ <p>Description</p>
+ </div>
+ </section>
+ `
+ return data
+ }
+}
+
+module.exports = () => {return new Shop()}