First install and index script

pull/1/head
Nishant Arora 9 years ago
parent 3e7e25c76d
commit 175b4c1b8e

Binary file not shown.

@ -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");
});

@ -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();

@ -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"
}
}

Loading…
Cancel
Save