Skip to content

Commit

Permalink
Merge pull request #124 from aquariophilie/feature/validation_and_lookup
Browse files Browse the repository at this point in the history
Feature/validation and lookup
  • Loading branch information
gmacario authored Nov 24, 2021
2 parents 94bfe26 + 2a1960a commit b4350bd
Show file tree
Hide file tree
Showing 20 changed files with 267 additions and 129 deletions.
11 changes: 11 additions & 0 deletions .github/linters/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-empty-interface": 0
}
}
4 changes: 2 additions & 2 deletions .github/linters/.htmlhintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"spec-char-escape": true,
"id-unique": false,
"src-not-empty": true,
"title-require": false,
"title-require": true,
"alt-require": true,
"doctype-html5": true,
"id-class-value": false,
Expand All @@ -21,5 +21,5 @@
"id-class-ad-disabled": false,
"href-abs-or-rel": false,
"attr-unsafe-chars": true,
"head-script-disabled": false
"head-script-disabled": true
}
5 changes: 5 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ jobs:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: .*vscode/.*.json
VALIDATE_JAVASCRIPT_STANDARD: false
TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.json
VALIDATE_TYPESCRIPT_STANDARD: false
VALIDATE_MARKDOWN: false
1 change: 1 addition & 0 deletions client/src/app.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Blobfishes app</title>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.png" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
Expand Down
31 changes: 31 additions & 0 deletions client/src/lib/api.author.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import axios from 'axios'
import {
API_PATH
} from './api';

const apiAuthorPath = `${API_PATH}/author`;

function findAuthors() {
return axios.get(apiAuthorPath);
}

function insertAuthor(payload) {
return axios.post(apiAuthorPath, payload);
}

function updateAuthor(id, payload) {
const path = `${apiAuthorPath}/${id}`;
return axios.put(path, payload);
}

function removeAuthor(id) {
const path = `${apiAuthorPath}/${id}`;
return axios.delete(path);
}

export const apiAuthor = {
findAuthors,
insertAuthor,
updateAuthor,
removeAuthor
}
31 changes: 31 additions & 0 deletions client/src/lib/api.book.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import axios from 'axios'
import {
API_PATH
} from './api';

const apiBookPath = `${API_PATH}/book`;

function findBooks() {
return axios.get(apiBookPath);
}

function insertBook(payload) {
return axios.post(apiBookPath, payload);
}

function updateBook(id, payload) {
const path = `${apiBookPath}/${id}`;
return axios.put(path, payload);
}

function removeBook(id) {
const path = `${apiBookPath}/${id}`;
return axios.delete(path);
}

export const apiBook = {
findBooks,
insertBook,
updateBook,
removeBook
}
1 change: 1 addition & 0 deletions client/src/lib/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const API_PATH = '/api';
14 changes: 0 additions & 14 deletions client/src/lib/requests.js

This file was deleted.

18 changes: 5 additions & 13 deletions client/src/routes/authors.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
import axios from "axios";
import { onMount } from "svelte";
import {
Button,
Expand All @@ -14,8 +13,7 @@
Label,
Table,
} from "sveltestrap";
const apiPath = "/api/author";
import { apiAuthor } from "../lib/api.author";
var authors = [];
var addAuthorForm = {
Expand All @@ -28,15 +26,13 @@
let updateopen = false;
function getAuthors() {
axios.get(`${apiPath}`).then((res) => {
apiAuthor.findAuthors().then((res) => {
authors = res.data;
});
}
function deleteAuthor(author) {
const path = `${apiPath}/${author._id}`;
axios
.delete(path)
apiAuthor.removeAuthor(author._id)
.then(() => {
getAuthors();
})
Expand All @@ -55,13 +51,11 @@
}
function addAuthor() {
const path = `${apiPath}`;
const payload = {
name: addAuthorForm.name,
bio: addAuthorForm.bio,
};
axios
.post(path, payload)
apiAuthor.insertAuthor(payload)
.then(() => {
getAuthors();
})
Expand All @@ -74,13 +68,11 @@
}
function updateAuthor() {
const path = `${apiPath}/${addAuthorForm._id}`;
const payload = {
name: addAuthorForm.name,
bio: addAuthorForm.bio,
};
axios
.put(path, payload)
apiAuthor.updateAuthor(addAuthorForm._id, payload)
.then(() => {
getAuthors();
})
Expand Down
Loading

0 comments on commit b4350bd

Please sign in to comment.