Skip to content

Commit

Permalink
Merge pull request #11 from philippebeck/dev
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
philippebeck authored Feb 1, 2023
2 parents 1336da4 + 4cfe0c7 commit 57d6fac
Show file tree
Hide file tree
Showing 29 changed files with 445 additions and 206 deletions.
18 changes: 9 additions & 9 deletions api/controller/ArticleCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ exports.getImgName = (name) => {
* @param {string} alt
* @param {number} price
* @param {string} cat
* @param {string} createdDate
* @param {string} updatedDate
* @param {string} created
* @param {string} updated
* @returns
*/
exports.getArticle = (name, description, image, alt, price, cat, createdDate, updatedDate) => {
exports.getArticle = (name, description, image, alt, price, cat, created, updated) => {

return {
name: name,
Expand All @@ -45,8 +45,8 @@ exports.getArticle = (name, description, image, alt, price, cat, createdDate, up
alt: alt,
price: price,
cat: cat,
createdDate: createdDate,
updatedDate: updatedDate
created: created,
updated: updated
}
}

Expand Down Expand Up @@ -93,8 +93,8 @@ exports.createArticle = (req, res, next) => {
fields.alt,
fields.price,
fields.cat,
fields.createdDate,
fields.updatedDate
fields.created,
fields.updated
));

article
Expand Down Expand Up @@ -161,8 +161,8 @@ exports.updateArticle = (req, res, next) => {
fields.alt,
fields.price,
fields.cat,
fields.createdDate,
fields.updatedDate
fields.created,
fields.updated
);

ArticleModel
Expand Down
26 changes: 13 additions & 13 deletions api/controller/PostCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ exports.getImgName = (name) => {
* @param {string} image
* @param {string} alt
* @param {string} cat
* @param {string} userId
* @param {string} createdDate
* @param {string} updatedDate
* @param {string} user
* @param {string} created
* @param {string} updated
* @param {number} likes
* @param {array} usersLiked
* @returns
*/
exports.getPost = (title, text, image, alt, cat, userId, createdDate, updatedDate, likes, usersLiked) => {
exports.getPost = (title, text, image, alt, cat, user, created, updated, likes, usersLiked) => {

return {
title: title,
text: text,
image: image,
alt: alt,
cat: cat,
userId: userId,
createdDate: createdDate,
updatedDate: updatedDate,
user: user,
created: created,
updated: updated,
likes: likes,
usersLiked: usersLiked
}
Expand Down Expand Up @@ -95,9 +95,9 @@ exports.createPost = (req, res, next) => {
image,
fields.alt,
fields.cat,
fields.userId,
fields.createdDate,
fields.updatedDate,
fields.user,
fields.created,
fields.updated,
fields.likes,
fields.usersLiked,
));
Expand Down Expand Up @@ -165,9 +165,9 @@ exports.updatePost = (req, res, next) => {
image,
fields.alt,
fields.cat,
fields.userId,
fields.createdDate,
fields.updatedDate,
fields.user,
fields.created,
fields.updated,
fields.likes,
fields.usersLiked
);
Expand Down
27 changes: 16 additions & 11 deletions api/controller/UserCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,23 @@ exports.getImgName = (name) => {
* @param {string} email
* @param {string} image
* @param {string} alt
* @param {string} role
* @param {string} pass
* @param {string} createdDate
* @param {string} updatedDate
* @param {string} created
* @param {string} updated
* @returns
*/
exports.getUser = (name, email, image, alt, pass, createdDate, updatedDate) => {
exports.getUser = (name, email, image, alt, role, pass, created, updated) => {

return {
name: name,
email: email,
image: image,
alt: alt,
role: role,
pass: pass,
createdDate: createdDate,
updatedDate: updatedDate
created: created,
updated: updated
}
}

Expand Down Expand Up @@ -146,9 +148,10 @@ exports.forgotPass = (req, res, next) => {
user.email,
user.image,
user.alt,
user.role,
hash,
user.createdDate,
user.updatedDate
user.created,
user.updated
);

UserModel
Expand Down Expand Up @@ -195,9 +198,10 @@ exports.createUser = (req, res, next) => {
fields.email,
image,
fields.alt,
fields.role,
hash,
fields.createdDate,
fields.updatedDate
fields.created,
fields.updated
));

fs.unlink(usersUrl + files.image.newFilename, () => {
Expand Down Expand Up @@ -255,9 +259,10 @@ exports.updateUser = (req, res, next) => {
fields.email,
image,
fields.alt,
fields.role,
hash,
fields.createdDate,
fields.updatedDate
fields.created,
fields.updated
);

UserModel
Expand Down
4 changes: 2 additions & 2 deletions api/model/ArticleModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const ArticleModel = mongoose.Schema(
type: String,
required: true
},
createdDate: {
created: {
type: Date,
required: true
},
updatedDate: {
updated: {
type: Date,
required: true
}
Expand Down
8 changes: 4 additions & 4 deletions api/model/CommentModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ const CommentModel = mongoose.Schema(
type: String,
required: true
},
postId: {
post: {
type: String,
required: true
},
userId: {
user: {
type: String,
required: true
},
createdDate: {
created: {
type: Date,
required: true
},
updatedDate: {
updated: {
type: Date,
required: true
}
Expand Down
6 changes: 3 additions & 3 deletions api/model/PostModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const PostModel = mongoose.Schema(
type: String,
required: true
},
userId: {
user: {
type: String,
required: true
},
createdDate: {
created: {
type: Date,
required: true
},
updatedDate: {
updated: {
type: Date,
required: true
},
Expand Down
8 changes: 4 additions & 4 deletions api/model/ReviewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ const ReviewModel = mongoose.Schema(
type: Number,
required: true
},
articleId: {
article: {
type: String,
required: true
},
userId: {
user: {
type: String,
required: true
},
createdDate: {
created: {
type: Date,
required: true
},
updatedDate: {
updated: {
type: Date,
required: true
}
Expand Down
8 changes: 6 additions & 2 deletions api/model/UserModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ const UserModel = mongoose.Schema(
type: String,
required: true
},
role: {
type: String,
default: "user"
},
pass: {
type: String,
required: true
},
createdDate: {
created: {
type: Date,
required: true
},
updatedDate: {
updated: {
type: Date,
required: true
}
Expand Down
3 changes: 3 additions & 0 deletions api/route/ArticleRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ const nem = require("nemjs");

const ArticleCtrl = require("../controller/ArticleCtrl");

/* Public */
router.get("/", ArticleCtrl.listArticles);
router.get("/:id", ArticleCtrl.readArticle);

/* Private */
router.post("/", nem.checkAuth, ArticleCtrl.createArticle);
router.put("/:id", nem.checkAuth, ArticleCtrl.updateArticle);
router.delete("/:id", nem.checkAuth, ArticleCtrl.deleteArticle);
Expand Down
3 changes: 3 additions & 0 deletions api/route/CommentRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const nem = require("nemjs");

const CommentCtrl = require("../controller/CommentCtrl");

/* Public */
router.get("/", CommentCtrl.listComments);

/* Private */
router.post("/", nem.checkAuth, CommentCtrl.createComment);
router.put("/:id", nem.checkAuth, CommentCtrl.updateComment);
router.delete("/:id", nem.checkAuth, CommentCtrl.deleteComment);
Expand Down
3 changes: 3 additions & 0 deletions api/route/PostRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ const nem = require("nemjs");

const PostCtrl = require("../controller/PostCtrl");

/* Public */
router.get("/", PostCtrl.listPosts);
router.get("/:id", PostCtrl.readPost);

/* Private */
router.post("/", nem.checkAuth, PostCtrl.createPost);
router.put("/:id", nem.checkAuth, PostCtrl.updatePost);
router.delete("/:id", nem.checkAuth, PostCtrl.deletePost);
Expand Down
3 changes: 3 additions & 0 deletions api/route/ReviewRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const nem = require("nemjs");

const ReviewCtrl = require("../controller/ReviewCtrl");

/* Public */
router.get("/", ReviewCtrl.listReviews);

/* Private */
router.post("/", nem.checkAuth, ReviewCtrl.createReview);
router.put("/:id", nem.checkAuth, ReviewCtrl.updateReview);
router.delete("/:id", nem.checkAuth, ReviewCtrl.deleteReview);
Expand Down
7 changes: 5 additions & 2 deletions api/route/UserRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ const nem = require("nemjs");

const UserCtrl = require("../controller/UserCtrl");

router.get("/", nem.checkAuth, UserCtrl.listUsers);
/* Public */
router.post("/login", UserCtrl.loginUser);
router.post("/forgot", UserCtrl.forgotPass);
router.post("/send", UserCtrl.sendMessage);

/* Private */
router.get("/", nem.checkAuth, UserCtrl.listUsers);
router.post("/", nem.checkAuth, UserCtrl.createUser);
router.put("/:id", nem.checkAuth, UserCtrl.updateUser);
router.delete("/:id", nem.checkAuth, UserCtrl.deleteUser);
router.post("/send", UserCtrl.sendMessage);

module.exports = router;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vesan",
"version": "0.5.0",
"version": "0.6.0",
"description": "CMS with Vue-Elt, Servidio, Animadio & NemJS",
"keywords": [
"cms",
Expand Down
12 changes: 8 additions & 4 deletions src/components/CreateArticle.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<CardElt>
<CardElt id="create-article">
<template #header>
<i class="fa-solid fa-basket-shopping fa-2x"></i>
<h3>Create Article</h3>
Expand Down Expand Up @@ -60,6 +60,7 @@
<!-- Article Alt -->
<template #item-4>
<FieldElt id="article-alt"
type="textarea"
v-model:value="alt"
info="Alternative text">
<template #legend>
Expand Down Expand Up @@ -96,7 +97,7 @@
v-model:value="cat"
info="Choose a category"
@keyup.enter="validateNewArticle()"
:list="['sauce']">
:list="cats">
<template #legend>
Category
</template>
Expand All @@ -120,6 +121,9 @@
<script>
export default {
name: "CreateArticle",
props: {
cats: {}
},
data() {
return {
Expand Down Expand Up @@ -189,8 +193,8 @@ export default {
article.append("alt", this.alt);
article.append("price", this.price);
article.append("cat", this.cat);
article.append("createdDate", Date.now());
article.append("updatedDate", Date.now());
article.append("created", Date.now());
article.append("updated", Date.now());
this.$serve.postData("/api/articles", article)
.then(() => {
Expand Down
Loading

0 comments on commit 57d6fac

Please sign in to comment.