-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute.js
108 lines (105 loc) · 3.02 KB
/
route.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'use strict';
const server = require('./server.js');
const Path = require('path');
const Hoek = require('hoek');
const handlebars = require('handlebars');
const article = require('./Controllers/articles.js');
const main = require('./Controllers/main.js');
const Joi = require('joi');
const files = {
method: 'GET',
path: '/assets/{file*}',
handler: {
directory: {
path: 'public/assets/'
}
}
}
const images = {
method: 'GET',
path: '/images/{file*}',
handler: {
directory: {
path: 'public/assets/images'
}
}
}
const home = {
method: 'GET',
path: '/',
handler: function(request, reply) {
main.SelectData(request, reply);
}
}
const login = {
method: 'POST',
path: '/login',
handler: function(request, reply) {
main.login(request, reply);
},config: {
validate: {
payload: {
password: Joi.number().integer().required(),
email: Joi.string().email().required(),
}
}
}
}
const articleid = {
method: 'GET',
path: '/article/{id}',
handler: function(request, reply) {
main.article(request, reply);
}
}
const CreatearticleGET = {
method: 'GET',
path: '/admin/CreateArticle',
handler: function(request, reply) {
const data = {
title: 'CreateArticle',
subtitle: 'Create Article',
info: 'You Can Add Articles'
}
reply.view("CreateArticle", data);
}
}
const CreateArticlePOST = {
method: 'POST',
path: '/admin/CreateArticle',
handler: function(request, reply) {
const data = {
title: 'CreateArticle',
subtitle: 'Create Article',
info: 'You Can Add Articles'
}
article.insertData(request, reply);
},config: {
validate: {
payload: {
title: Joi.string().required(),
category_id: Joi.number().integer().required(),
summary: Joi.string().required(),
details: Joi.string().required(),
image: Joi.string().required().regex(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/
),
active: Joi.number(),
}
}
}
}
const ArticleDelete = {
method: 'GET',
path: '/admin/Article/delete/{id}',
handler: function(request, reply) {
article.DeleteData(request, reply);
}
}
const DisplayArticles = {
method: 'GET',
path: '/admin/DisplayArticles',
handler: function(request, reply) {
article.SelectData(request, reply);
}
}
module.exports = [files, images, home, login, articleid, CreatearticleGET, CreateArticlePOST, ArticleDelete, DisplayArticles]