Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
193 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
const sqlite = require('sqlite-async') | ||
|
||
|
||
module.exports = class List { | ||
|
||
constructor(dbName = ':memory:') { | ||
return (async() => { | ||
this.db = await sqlite.open(dbName) | ||
//we need this table to store the user track | ||
const sql = 'CREATE TABLE IF NOT EXISTS uploadTrack\ | ||
(id TEXT, singer_name TEXT, singer_details TEXT, description TEXT,image_url TEXT, Track_name TEXT;' | ||
await this.db.run(sql) | ||
return this | ||
console.log("Track open") | ||
})() | ||
} | ||
|
||
/** | ||
* checks to see if a set of login credentials are valid | ||
* @param {String} username the username to check | ||
* @param {String} password the password to check | ||
* @returns {Boolean} returns true if credentials are valid | ||
*/ | ||
async register(user, pass, email) { | ||
Array.from(arguments).forEach( val => { | ||
if(val.length === 0) throw new Error('missing field') | ||
}) | ||
let sql = `SELECT COUNT(id) as records FROM artist WHERE user="${user}";` | ||
const data = await this.db.get(sql) | ||
if(data.records !== 0) throw new Error(`username "${user}" already in use`) | ||
sql = `SELECT COUNT(id) as records FROM artist WHERE email="${email}";` | ||
const emails = await this.db.get(sql) | ||
if(emails.records !== 0) throw new Error(`email address "${email}" is already in use`) | ||
pass = await bcrypt.hash(pass, saltRounds) | ||
sql = `INSERT INTO artist(user, pass, email) VALUES("${user}", "${pass}", "${email}")` | ||
await this.db.run(sql) | ||
return true | ||
} | ||
|
||
async getAll() { | ||
|
||
|
||
} | ||
|
||
async tearDown() { | ||
await this.db.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
const sqlite = require('sqlite-async') | ||
|
||
|
||
module.exports = class UploadTrack { | ||
|
||
constructor(dbName = ':memory:') { | ||
console.log("constructor") | ||
return (async() => { | ||
this.db = await sqlite.open(dbName) | ||
const sql = 'CREATE TABLE IF NOT EXISTS uploadTrack\ | ||
(id TEXT, singer_name TEXT, singer_details TEXT, description TEXT,image_url TEXT, Track_name TEXT);' | ||
await this.db.run(sql) | ||
return this | ||
})() | ||
} | ||
|
||
async insert(id, singer_name, singer_details,description,track,image_url) { | ||
sql = `INSERT INTO uploadTrack(id, singer_name, singer_details,description,image_url,Track_name) VALUES("${id}", "${singer_name}", "${singer_details}", "${description}", "${image_url}", "${track}")` | ||
await this.db.run(sql) | ||
console.log("Done") | ||
return true | ||
} | ||
|
||
async getAll() { | ||
sql = `SELECT * FROM uploadTrack` | ||
const record = await this.db.get(sql) | ||
return record | ||
|
||
|
||
} | ||
|
||
async tearDown() { | ||
await this.db.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
<!doctype html> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Playlist</title> | ||
<meta name="description" content="form to add new books"> | ||
<meta name="author" content="Mark Tyers"> | ||
<link href="{{host}}/style.css" type="text/css" rel="stylesheet" /> | ||
|
||
</script> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>PlayList</h1> | ||
</header> | ||
{{#if msg}} | ||
<p class="msg">{{msg}}</p> | ||
{{/if}} | ||
|
||
<br> | ||
<br> | ||
<table border="1" align="center" cellspacing="20"> | ||
<tr> | ||
<th>Singer-Name</th> | ||
<th>Track</th> | ||
<th>Action</th> | ||
|
||
</tr> | ||
{{#each record}} | ||
|
||
<tr> | ||
<td><a href="/singerDetails/{{Singer_Name}}">{{Singer_Name}}</a></td> <td><a href="/trackDetails/{{Track_Name}}">{{Track_Name}}</a></td> | ||
</tr> | ||
{{/each}} | ||
</table> | ||
<br> | ||
|
||
<center><a href="/logout">Logout</a></center> | ||
|
||
|
||
|
||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters