diff --git a/db/matterwiki.sqlite b/db/matterwiki.sqlite new file mode 100644 index 0000000..01f495a Binary files /dev/null and b/db/matterwiki.sqlite differ diff --git a/index.js b/index.js index e69de29..989c401 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,15 @@ +/* +This is main file which will contain all of our endpoints. +Once we have enough endpoints defined we start breaking them into modules for better code readability +*/ + +var express = require('express'); +var app = express(); + +app.get('/',function(req,res){ + res.send("Hey! You're looking at the matterwiki API"); +}); + +app.listen(5000 || process.env.PORT, function(){ + console.log("The magic is happening on port 5000"); +}); diff --git a/install.js b/install.js new file mode 100755 index 0000000..673664d --- /dev/null +++ b/install.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +/* +This script will be executed on the command "wiki". It is defined under the "bin" key in the package.json file. +This is where we will write the complete setup script. +Creating tables. Filling them with initial data. Creating the first user. + +We're still looking for better names for the command. Should be matterwiki or just wiki? +*/ +var sqlite3 = require('sqlite3').verbose(); +var db = new sqlite3.Database('./db/matterwiki.sqlite'); + +console.log('Installation Started!'); + +db.serialize(function() { + db.run("CREATE TABLE articles (title TEXT)"); + var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); + for (var i = 0; i < 10; i++) { + stmt.run("Ipsum " + i); + } + stmt.finalize(); + db.each("SELECT rowid AS id, info FROM lorem", function(err, row) { + console.log(row.id + ": " + row.info); + }); +}); +db.close(); diff --git a/package.json b/package.json index d493fd2..42735a9 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, + "bin": { + "wiki": "./install.js" + }, "repository": { "type": "git", "url": "git+https://github.com/nshntarora/matterwiki.git" @@ -15,5 +18,9 @@ "bugs": { "url": "https://github.com/nshntarora/matterwiki/issues" }, - "homepage": "https://github.com/nshntarora/matterwiki#readme" + "homepage": "https://github.com/nshntarora/matterwiki#readme", + "dependencies": { + "express": "^4.14.0", + "sqlite3": "^3.1.4" + } }