Skip to content

Commit 5a546e7

Browse files
committed
Added uuid
Added new service methods
1 parent f62e724 commit 5a546e7

File tree

5 files changed

+54
-11
lines changed

5 files changed

+54
-11
lines changed

.env

-1
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ testem.log
4444
# System Files
4545
.DS_Store
4646
Thumbs.db
47+
48+
.vercel

package-lock.json

+29-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"showdown": "^1.9.1",
3838
"tslib": "^2.1.0",
3939
"tsparticles": "^1.32.0",
40+
"uuid": "^8.3.2",
4041
"zero-md": "^2.2.0",
4142
"zone.js": "~0.11.4"
4243
},
@@ -47,6 +48,7 @@
4748
"@types/jasmine": "~3.6.0",
4849
"@types/marked": "^2.0.4",
4950
"@types/node": "^12.20.16",
51+
"@types/uuid": "^8.3.1",
5052
"jasmine-core": "~3.7.0",
5153
"karma": "~6.3.0",
5254
"karma-chrome-launcher": "~3.1.0",

src/app/services/harperdb.service.ts

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Injectable } from "@angular/core";
22
import { environment } from "environments/environment";
3+
import { v4 as uuidv4 } from 'uuid';
34
@Injectable()
45
export class HarperDbService {
5-
6+
private REST_API = 'https://api.flashcoll.com';
67
private harpedAPI = environment.HARPERDB_API;
78
myHeaders = new Headers();
89
userData: any;
@@ -40,11 +41,12 @@ export class HarperDbService {
4041

4142
async generateUserSubprofileIfNotExist(userId: string) {
4243
let userdata: any;
43-
await fetch(`https://flashcoll-backend.glitch.me/clerk/user/${userId}`)
44+
await fetch(`${this.REST_API}/clerk/user/${userId}`)
4445
.then(data => {
4546
return userdata = data.json();
4647
}).then(userData => {
47-
fetch(`https://flashcoll-backend.glitch.me/github/user/${userData.external_accounts[0].provider_user_id}`)
48+
console.log(userData);
49+
fetch(`${this.REST_API}/github/user/${userData.external_accounts[0].provider_user_id}`)
4850
.then(response => {
4951
let json = response.json();
5052
json.then(result => {
@@ -86,11 +88,24 @@ export class HarperDbService {
8688
return await this.runSQLOnHarperDB(sqlQuery);
8789
}
8890

89-
async createNewProject(userData: any) {
91+
async createNewProject(userData: any, projectData: any) {
9092
const sqlQuery = `INSERT INTO flashcoll.project
91-
(id, userProfileID, githubRepoURL)
92-
VALUE ("${''}")`;
93+
(id, userProfileID, githubRepoURL, projectTitle, projectShortDescription)
94+
VALUE ("${uuidv4()}", "${userData.id}", "${projectData.githubRepoURL}", "${projectData.projectTitle}", "${projectData.shortDescription}")`;
95+
return await this.runSQLOnHarperDB(sqlQuery);
9396
}
97+
98+
async getAllUserProjects(userId: string) {
99+
const sqlQuery = `SELECT * FROM flashcoll.project where userProfileID = "${userId}"`;
100+
return await this.runSQLOnHarperDB(sqlQuery);
101+
}
102+
103+
async getProjectDetails(projectId: string) {
104+
const sqlQuery = `SELECT * FROM flashcoll.project where id = "${projectId}"`;
105+
return await this.runSQLOnHarperDB(sqlQuery);
106+
}
107+
108+
94109
//#endregion
95110

96111
}

0 commit comments

Comments
 (0)