Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #29

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ DEFAULT_PORT=":8000"
ASSETS_PATH="dist/assets/"
HTML_PATH="dist/index.html"
DB_PATH="api/database/db.sql"
DB_INIT="api/database/TableInit.txt"
DB_INIT="api/database/db-init"
PATH_TO_VITE="%appdata%/npm/vite.cmd"
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/assets/index.js
dist/assets/**/*
.vscode/setting.json
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"browser": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:solid/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "jsdoc"],
"plugins": ["jsdoc", "solid"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"indent": ["off", "tab"],
Expand All @@ -22,6 +22,7 @@
"id-length": ["error", {"min": 2, "exceptions": ["_"], "properties": "never"}],
"no-underscore-dangle":"error",

"solid/no-array-handlers": "error",
"eslint-plugin-import/no-unresolved": "off",
"@typescript-eslint/no-namespace": "off",
"jsdoc/check-access": 1, // Recommended
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"svg.preview.background": "editor"
}
30 changes: 0 additions & 30 deletions api/database/TableInit.txt

This file was deleted.

41 changes: 41 additions & 0 deletions api/database/db-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
CREATE TABLE Images (
URL TEXT PRIMARY KEY,
content BLOB,
mimetype TEXT
);

CREATE TABLE Posts (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
PostedBy INTEGER,
content TEXT,

likes INTEGER DEFAULT 0,
whoLiked TEXT NOT NULL DEFAULT "",

dislikes INTEGER DEFAULT 0,
whoDisliked TEXT NOT NULL DEFAULT "",

timeCreated DATETIME,
parentID INTEGER,
images TEXT
);

CREATE TABLE Users (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT,
password BLOB,
handle TEXT UNIQUE,
email TEXT NULL,
bio TEXT DEFAULT "",

auth TEXT NOT NULL,
timeCreated DATETIME,

Followers NUMBER DEFAULT 0,
whoFollowed TEXT DEFAULT "",

posts INTEGER DEFAULT 0,

profile TEXT DEFAULT "",
banner TEXT DEFAULT ""
);
4 changes: 2 additions & 2 deletions api/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

// ImageData contains the URL, content, content-type of an image
type ImageData struct {
URL string `db:"url"`
Content []byte `db:"Content"`
URL string `db:"URL"`
Content []byte `db:"content"`
ContentType string `db:"mimetype"`
}

Expand Down
13 changes: 8 additions & 5 deletions api/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ type AddPostRequest struct {

// PostDB is a struct replicata of the `Posts` table
type PostDB struct {
ID int `json:"ID" db:"id"`
PostedBy int `json:"postedBy" db:"PostedBy"`
ID int `json:"ID" db:"ID"`
PostedBy int `json:"postedBy" db:"postedBy"`
Content string `json:"content" db:"content"`
TimeCreated time.Time `json:"timeCreated" db:"timeCreated"`
ParentID int `json:"parentID" db:"ParentId"`
// Images list format seperated with commas: url (alt)
Images string `json:"images" db:"images"`
ParentID int `json:"parentID" db:"parentID"`
WhoLiked string `json:"whoLiked" db:"whoLiked"`
WhoDisliked string `json:"whoDisliked" db:"whoDisliked"`
Likes int `json:"likes" db:"likes"`
Dislikes int `json:"dislikes" db:"dislikes"`
Images string `json:"images" db:"images"`
}

// PostListBody is used by [coffeecoserver/api.server.PostFeedList] and only contains Amount int value.
Expand Down
26 changes: 9 additions & 17 deletions api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ type LoginUser struct {

// PublicUser is the root of most User structs contains non-personal information about the user
type PublicUser struct {
ID int `json:"ID" db:"id"`
Username string `json:"username" db:"username"` // A non-unique name
Handle string `json:"handle" db:"handle"` // An unique handle
Bio string `json:"bio" db:"bio"` // The description (biography)
FollowersCount int `json:"followersCount" db:"followersCount"` // How many users following
Banner string `json:"Banner" db:"Banner"` // Url to the Banner
Profile string `json:"Profile" db:"Profile"` // Url to the Profile
ID int `json:"ID" db:"ID"`
Username string `json:"username" db:"username"` // A non-unique name
Handle string `json:"handle" db:"handle"` // An unique handle
Bio string `json:"bio" db:"bio"` // The description (biography)
Followers int `json:"followers" db:"followers"`
WhoFollowed string `json:"whoFollowed" db:"whoFollowed"` // How many users following
Banner string `json:"Banner" db:"banner"` // Url to the Banner
Profile string `json:"Profile" db:"profile"` // Url to the Profile
}

// SentUser contains all the regular information from [coffeecoserver/api.PublicUser] as well as:
Expand Down Expand Up @@ -129,16 +130,7 @@ func (srv *Server) APIUserFromID(w http.ResponseWriter, r *http.Request) {
return
}

type UFIUser struct {
Username string `json:"username"`
Handle string `json:"handle"`
FollowersCount int `json:"followersCount"`
Banner string `json:"Banner"`
Profile string `json:"Profile"`
Bio string `json:"bio"`
}

var u UFIUser
var u PublicUser
if err := scan.Row(&u, rows); err != nil {
utility.SendScanErr(w, err, nil)
return
Expand Down
File renamed without changes.
Loading
Loading