Initial commit

This commit is contained in:
Ajay Ramachandran 2019-07-09 13:48:03 -04:00
commit ca479bc2f7
4 changed files with 1306 additions and 0 deletions

91
.gitignore vendored Normal file
View file

@ -0,0 +1,91 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# Databases
databases

44
index.js Normal file
View file

@ -0,0 +1,44 @@
var express = require('express');
var http = require('http');
// Create a service (the app object is just a callback).
var app = express();
//load database
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('./databases/sponsorTimes.db');
// Create an HTTP service.
http.createServer(app).listen(80);
//add the get function
app.get('/api/get', function (req, res) {
let videoID = req.query.videoID;
let sponsorTimes = [];
db.prepare("SELECT startTime, endTime FROM sponsorTimes WHERE videoID = ?").all(videoID, function(err, rows) {
if (err) console.log(err);
for (let i = 0; i < rows.length; i++) {
sponsorTimes[i] = [];
sponsorTimes[i][0] = rows[i].startTime;
sponsorTimes[i][1] = rows[i].endTime;
}
//send result
res.send({
sponsorTimes: sponsorTimes
})
});
});
//add the post function
app.get('/api/get', function (req, res) {
});
app.get('/downloadDatabase', function (req, res) {
res.sendFile("./databases/sponsorTimes.db");
});

1154
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

17
package.json Normal file
View file

@ -0,0 +1,17 @@
{
"name": "sponsor_block_server",
"version": "0.1.0",
"description": "Server that holds the SponsorBlock database",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "Ajay Ramachandran",
"license": "MIT",
"dependencies": {
"express": "^4.17.1",
"http": "0.0.0",
"sqlite3": "^4.0.9"
}
}