Compare commits

..

2 Commits

Author SHA1 Message Date
DutchEllie da55b65a42
Add music table, but neglect actually doing something with it
continuous-integration/drone/push Build was killed Details
2022-08-22 16:15:38 +02:00
DutchEllie 62bac12144
Simple database concept 2022-08-20 13:13:40 +02:00
17 changed files with 1813 additions and 180 deletions

View File

@ -1,3 +1,8 @@
apiVersion: v2
name: newsite
version: v0.0.3
version: v0.0.4
dependencies:
- name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 11.1.8

View File

@ -27,3 +27,15 @@ ingress:
paths:
- path: /
pathType: Prefix
mariadb:
auth:
database: website
username: ellie
password: ellie
rootPassword: ellie
primary:
service:
port: 3306
persistence:
size: 3Gi

View File

@ -1,6 +1,8 @@
baseURL: changeme.dutchellie.nl
name: changeme-prod
containerEnv:
- name: NODE_ENV
value: production
# - name: APIURL
# value: https://api.quenten.nl/api
service:

View File

@ -1,6 +1,8 @@
baseURL: changemestaging.dutchellie.nl
name: changeme-staging
containerEnv:
- name: NODE_ENV
value: staging
# - name: APIURL
# value: https://api.quenten.nl/api/testing
service:

1766
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,8 @@
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
"format": "prettier --write --plugin-search-dir=. ."
"format": "prettier --write --plugin-search-dir=. .",
"knex": "node --loader ts-node/esm node_modules/.bin/knex --knexfile src/lib/db/knexfile.ts"
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
@ -38,7 +39,11 @@
"type": "module",
"dependencies": {
"js-sha256": "^0.9.0",
"knex": "^2.2.0",
"mysql2": "^2.3.3",
"sqlite3": "^5.0.11",
"svelte-gestures": "^1.4.1",
"svelte-language-server": "^0.14.29"
"svelte-language-server": "^0.14.29",
"ts-node": "^10.9.1"
}
}

View File

@ -6,8 +6,8 @@
</script>
<div>
Hi, I am Quenten (aka, DutchEllie). I am the creator of this website. Thanks for checking it out! I
made this website partly to have some project to express myself with and to learn some new skills.
Hi, I am DutchEllie. I am the creator of this website. Thanks for checking it out! I made this
website partly to have some project to express myself with and to learn some new skills.
<br />
<br />
I am a {years} year old person from The Netherlands. I am still a student and I am aspiring to be a
@ -22,16 +22,7 @@
class="underline text-[#002896] dark:text-blue-200 dark:hover:text-blue-50 hover:text-blue-500"
href="https://dutchellie.nl/DutchEllie/proper-website-2">DutchEllie/proper-website-2</a
>.
<br />
<br />
You can contact me if you want at
<a
class="underline text-[#002896] dark:text-blue-200 dark:hover:text-blue-50 hover:text-blue-500 "
href="mailto:contact@quenten.nl">contact@quenten.nl</a
>.
<br />
<br />
As for other things I like, here is a list!
<br>
<br>
As for other things, here is a list!
</div>

View File

@ -33,7 +33,7 @@
<div class="h-5 w-11/12 bg-indigo-300 rounded-xl" />
</div>
<div class="mb-1 h-5 flex-grow bg-indigo-900 rounded-xl">
<div class="h-5 w-3/12 bg-indigo-300 rounded-xl" />
<div class="h-5 w-2/12 bg-indigo-300 rounded-xl" />
</div>
<div class="mb-1 h-5 flex-grow rounded-xl">
<div class="h-5 w-7/12 rounded-xl" />
@ -45,7 +45,7 @@
<div class="h-5 w-8/12 bg-indigo-300 rounded-xl" />
</div>
<div class="mb-1 h-5 flex-grow bg-indigo-900 rounded-xl">
<div class="h-5 w-5/12 bg-indigo-300 rounded-xl" />
<div class="h-5 w-4/12 bg-indigo-300 rounded-xl" />
</div>
</div>
</ul>

View File

@ -2,12 +2,10 @@
import {fly} from "svelte/transition";
import {swipe} from "svelte-gestures";
import Button from './navbutton.svelte';
import { browser } from '$app/env';
export /**
* @type {any}
*/
let open;
$: if (browser) document.body.classList[open ? 'add' : 'remove']('overflow-hidden');
</script>
{#if open}

8
src/lib/db/db.ts Normal file
View File

@ -0,0 +1,8 @@
import knex from "knex";
import configs from "./knexfile";
const config = configs[process.env.NODE_ENV || "development"];
const db = knex(config);
export default db;

54
src/lib/db/knexfile.ts Normal file
View File

@ -0,0 +1,54 @@
import type { Knex } from "knex";
// Update with your config settings.
const config: { [key: string]: Knex.Config } = {
development: {
client: "sqlite3",
connection: {
filename: "/home/quenten/Documents/repos/dutchellie.nl/DutchEllie/svelte-website/src/lib/db/dev.sqlite3"
},
debug: true,
useNullAsDefault: true,
migrations: {
extension: 'ts',
}
},
staging: {
client: "mysql",
connection: {
database: "website_staging",
user: "ellie",
password: "ellie"
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: "knex_migrations",
extension: 'ts',
}
},
production: {
client: "mysql",
connection: {
database: "website",
user: "ellie",
password: "ellie"
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: "knex_migrations",
extension: 'ts',
}
}
};
export default config;

View File

@ -0,0 +1,19 @@
import type { Knex } from "knex";
export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable("users", (table) => {
table.increments("userid", { primaryKey: true });
table.string("username", 255).notNullable;
table.string("email", 255).notNullable;
table.string("password", 64).notNullable;
table.string("website", 255);
table.timestamps(true, true);
});
}
export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable("users");
}

View File

@ -0,0 +1,18 @@
import type { Knex } from "knex";
export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable("music", (table) => {
table.increments("musicid", { primaryKey: true });
table.string("ytlink", 255);
table.integer("userid");
table.foreign("userid").references("userid").inTable("users");
table.timestamps(true, true);
});
}
export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable("music");
}

26
src/lib/db/music.ts Normal file
View File

@ -0,0 +1,26 @@
import db from "./db";
import type User from "../entities/user";
import type Music from "../entities/music";
export function addSong(link: string, userid: number): Promise<number> {
const song: Music = {
ytlink: link,
userID: userid,
};
return db()
.insert(song)
.into("music")
.then((v) => {
return v[0];
});
}
export function getSongsByUserID(userid: number): Promise<Music[]> {
return db()
.select("*")
.from<Music>("music")
.where("userid", userid)
.then((v) => {
return v;
});
}

23
src/lib/db/user.ts Normal file
View File

@ -0,0 +1,23 @@
import db from "./db";
import type User from "../entities/user";
export function getID(userid: number): Promise<User | undefined>{
const user = db().select("*").from<User>("users").where("userid", userid).first().then((user) => {
return user;
});
return user;
};
export function createUser(username: string, email: string, website: string, password: string): Promise<number> {
return db()
.insert({
username: username,
email: email,
website: website,
password: password,
})
.into("users")
.then((n) => {
return n[0];
});
};

View File

@ -0,0 +1,9 @@
interface Music {
musicID?: number;
ytlink: string;
userID: number;
created_at?: Date,
updated_at?: Date,
}
export default Music;

11
src/lib/entities/user.ts Normal file
View File

@ -0,0 +1,11 @@
interface User {
userid: number,
username: string,
email: string,
password: string,
website?: string,
created_at: Date,
updated_at: Date,
};
export default User;