Skip to content

Commit

Permalink
Merge pull request #33 from JustalK/pre-dev
Browse files Browse the repository at this point in the history
[REFACTORING] Improving the portfolio page
  • Loading branch information
JustalK committed Oct 31, 2020
2 parents bbca3d2 + b4f5db4 commit 8336df3
Show file tree
Hide file tree
Showing 46 changed files with 1,760 additions and 1,201 deletions.
1,001 changes: 771 additions & 230 deletions dev/index.js

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions documentation/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ tags:
description: API Endpoints for the images for the images
- name: Tags
description: API Endpoints for the tags
- name: Contacts
description: API Endpoints for the contacts informations
- name: Pages
description: API Endpoints for the pages informations
#/** =============================================================================>
#===========================> API ARTICLES
#=============================================================================> **/
Expand Down Expand Up @@ -91,6 +95,64 @@ paths:
'500':
description: Server error
#/** =============================================================================>
#===========================> API CONTACTS
#=============================================================================> **/
/api/contacts/my-identity:
get:
tags:
- Contacts
summary: Get my contact information
description: ''
operationId: contacts
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
"$ref": "#/components/schemas/contacts"
'400':
description: Bad request
'401':
description: Unauthorized
'404':
description: Not Found
'500':
description: Server error
#/** =============================================================================>
#===========================> API PAGES
#=============================================================================> **/
/api/pages:
get:
tags:
- Pages
summary: Get my contact information
description: ''
operationId: pages
parameters:
- in: query
name: name
schema:
type: string
description: The name of the page
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
"$ref": "#/components/schemas/pages"
'400':
description: Bad request
'401':
description: Unauthorized
'404':
description: Not Found
'500':
description: Server error
#/** =============================================================================>
#===========================> MODEL
#=============================================================================> **/
components:
Expand Down Expand Up @@ -199,3 +261,74 @@ components:
default: 0
example: 12
readOnly: true
contacts:
type: object
required:
- firstname
- lastname
- email
properties:
_id:
type: uuid
firstname:
type: string
description: The firstname of the contact
lastname:
type: string
description: The lastname of the contact
fullname:
type: string
description: The fullname of the contact (virtual)
email:
type: string
description: The email of the contact
created_at:
type: date
description: The date of creation
example: '20/10/2018 10:00:12'
readOnly: true
updated_at:
type: date
description: The date of the last update
example: '20/10/2018 10:00:12'
readOnly: true
__v:
type: number
description: Number of update made since the creation
default: 0
example: 12
readOnly: true
pages:
type: object
required:
- name
- title
- description
properties:
_id:
type: uuid
name:
type: string
description: The name of the page
title:
type: string
description: The title of the page
description:
type: string
description: The description of the page
created_at:
type: date
description: The date of creation
example: '20/10/2018 10:00:12'
readOnly: true
updated_at:
type: date
description: The date of the last update
example: '20/10/2018 10:00:12'
readOnly: true
__v:
type: number
description: Number of update made since the creation
default: 0
example: 12
readOnly: true
28 changes: 14 additions & 14 deletions seeding/datas/articles/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ const mongoose = require('mongoose');

module.exports = [
{
"title": "Supersogo.com",
"slug": "supersogo",
"short_description": "My first project",
"long_description": "Just a test on my first project lalala al la lala la la lal a la",
"tags": [mongoose.Types.ObjectId("5f95461688489acdd8ee5873")],
"images": [],
"order": 0
title: "Supersogo.com",
slug: "supersogo",
short_description: "My first project",
long_description: "Just a test on my first project lalala al la lala la la lal a la",
tags: [mongoose.Types.ObjectId("5f95461688489acdd8ee5873")],
images: [],
order: 0
},
{
"slug": "title-2",
"title": "Title 2",
"short_description": "Bla bla bla bla 2",
"long_description": "Bla bla bla blaBla bla bla blaBla bla bla blaBla bla bla blaBla bla bla blaBla bla bla blaBla bla bla bla 2",
"tags": [mongoose.Types.ObjectId("5f95461688489acdd8ee5875")],
"images": [],
"order": 1
slug: "title-2",
title: "Title 2",
short_description: "Bla bla bla bla 2",
long_description: "Bla bla bla blaBla bla bla blaBla bla bla blaBla bla bla blaBla bla bla blaBla bla bla blaBla bla bla bla 2",
tags: [mongoose.Types.ObjectId("5f95461688489acdd8ee5875")],
images: [],
order: 1
}
]
11 changes: 11 additions & 0 deletions seeding/datas/pages/pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const mongoose = require('mongoose');

module.exports = [
{
name: "portfolio",
title: "Work",
description: "From Web Components and UI/UX animations to React.JS, Redux, Vue.JS, and Node.JS. Check out my latest web software development portfolio projects."
}
]
12 changes: 6 additions & 6 deletions seeding/datas/tags/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const mongoose = require('mongoose');

module.exports = [
{
"id": mongoose.Types.ObjectId("5f95461688489acdd8ee5873"),
"name": "Tag 01"
id: mongoose.Types.ObjectId("5f95461688489acdd8ee5873"),
name: "Tag 01"
},
{
"id": mongoose.Types.ObjectId("5f95461688489acdd8ee5874"),
"name": "Tag 02"
id: mongoose.Types.ObjectId("5f95461688489acdd8ee5874"),
name: "Tag 02"
},
{
"id": mongoose.Types.ObjectId("5f95461688489acdd8ee5875"),
"name": "Tag 03"
id: mongoose.Types.ObjectId("5f95461688489acdd8ee5875"),
name: "Tag 03"
}
]
12 changes: 12 additions & 0 deletions server/dbs/pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

const path = require('path');
const filename = path.basename(__filename, '.js');
const model = require('../models/' + filename);

module.exports = {
get_all: (find) => {
return model
.find(find);
}
};
5 changes: 5 additions & 0 deletions server/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ module.exports = {
if (module.exports.is_value_exist(value)) {
module.exports.add_filter(filters, key, { $all: value });
}
},
add_name_filter: (filters, key, value) => {
if (module.exports.is_value_exist(value)) {
module.exports.add_filter(filters, key, { $eq: value });
}
}
};
9 changes: 6 additions & 3 deletions server/models/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ const mongoose = require('mongoose');
const path = require('path');
const filename = path.basename(__filename, '.js');

// Define the article schema
const schema = new mongoose.Schema(
{
title: {
type: String
type: String,
trim: true,
require: true
},
slug: {
type: String
},
short_description: {
type: String,
trim: true,
require: true
},
long_description: {
type: String
type: String,
trim: true
},
tags: [ {
type: mongoose.Schema.Types.ObjectId,
Expand Down
1 change: 0 additions & 1 deletion server/models/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const mongoose = require('mongoose');
const path = require('path');
const filename = path.basename(__filename, '.js');

// Define the article schema
const schema = new mongoose.Schema(
{
firstname: {
Expand Down
9 changes: 6 additions & 3 deletions server/models/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ const mongoose = require('mongoose');
const path = require('path');
const filename = path.basename(__filename, '.js');

// Define the article schema
const schema = new mongoose.Schema(
{
name: {
type: String
type: String,
trim: true,
require: true
},
path: {
type: String
type: String,
trim: true,
require: true
}
},
{
Expand Down
34 changes: 34 additions & 0 deletions server/models/pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

const mongoose = require('mongoose');
const path = require('path');
const filename = path.basename(__filename, '.js');

const schema = new mongoose.Schema(
{
name: {
type: String,
lowercase: true,
trim: true,
require: true
},
title: {
type: String,
trim: true,
require: true
},
description: {
type: String,
trim: true,
require: true
}
},
{
timestamps: true,
collection: filename,
toJSON: { virtuals: true },
toObject: { virtuals: true }
}
);

module.exports = mongoose.model(filename, schema);
5 changes: 3 additions & 2 deletions server/models/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ const mongoose = require('mongoose');
const path = require('path');
const filename = path.basename(__filename, '.js');

// Define the article schema
const schema = new mongoose.Schema(
{
name: {
type: String
type: String,
trim: true,
require: true
}
},
{
Expand Down
19 changes: 19 additions & 0 deletions server/routes/pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

const express = require('express');
const routes = express.Router();
const path = require('path');
const filename = path.basename(__filename, '.js');
const dbs = require('../dbs/' + filename);
const services = require('../services/' + filename)(dbs);
const utils = require('../libs/utils');

// Return the list of all the articles
routes.route('/').get(async (request, response) => {
const params = {};
utils.add_name_filter(params, 'name', request.query.name);
const datas = await services.get_all(params);
response.json(datas);
});

module.exports = routes;
1 change: 1 addition & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
module.exports.adding_route('articles', '/api/articles', server);
module.exports.adding_route('tags', '/api/tags', server);
module.exports.adding_route('contacts', '/api/contacts', server);
module.exports.adding_route('pages', '/api/pages', server);
server.use(history());
server.use('/api/documentation', express.static('documentation'));
server.use('/', express.static('dev'));
Expand Down
7 changes: 7 additions & 0 deletions server/services/pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = dbs => ({
get_all: async (params) => {
return dbs.get_all(params);
}
});
Loading

0 comments on commit 8336df3

Please sign in to comment.