-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
261 lines (256 loc) · 4.42 KB
/
server.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/**
* @project Employees Contracts - https://employees-contracts-manager.onrender.com
* @fileoverview Defines routes, paths and nodejs server configs with expressjs.
* @author Obrymec - obrymecsprinces@gmail.com
* @created 2022-02-03
* @updated 2024-05-03
* @supported DESKTOP
* @file server.js
* @version 0.0.2
*/
// Plugin dependencies.
const controller = require ("./back_end/sources/api.js");
const parser = require ("body-parser");
const express = require ("express");
// Attributes.
const app = express ();
const port = 5200;
const options = {
root: `${__dirname}/front_end`
};
// App configurations.
app.use (parser.json ());
app.use (
parser.urlencoded ({
extended: true
})
);
app.use (
express.static (
options.root
)
);
// App routes.
app.get ('/', (_, res) => (
res.sendFile (
"./sources/features/sign_in_up/sign.html",
options
)
));
// Stops a contract
// web page view.
app.get (
"/stop-contract", (_, res) => (
res.sendFile (
"./sources/features/off_contract/stop_contract.html",
options
)
)
);
// Running contracts
// web page view.
app.get (
"/running-contracts", (_, res) => (
res.sendFile (
"./sources/features/get_running/running_contracts.html",
options
)
)
);
// Expired contracts
// web page view.
app.get (
"/expired-contracts", (_, res) => (
res.sendFile (
"./sources/features/get_expired/expired_contracts.html",
options
)
)
);
// Add contract web
// page view.
app.get (
"/add-contract", (_, res) => (
res.sendFile (
"./sources/features/put_contract/save_contract.html",
options
)
)
);
// Add mistake web
// page view.
app.get (
"/add-mistake", (_, res) => (
res.sendFile (
"./sources/features/put_mistake/save_mistake.html",
options
)
)
);
// Bad employees web
// page view.
app.get (
"/bad-employees", (_, res) => (
res.sendFile (
"./sources/features/get_mistake/employees_mistake.html",
options
)
)
);
// Busy employees web
// page view.
app.get (
"/busy-employees", (_, res) => (
res.sendFile (
"./sources/features/get_contract/employees_contract.html",
options
)
)
);
// Override contract
// web page view.
app.get (
"/override-contract", (_, res) => (
res.sendFile (
"./sources/features/set_contract/override_contract.html",
options
)
)
);
// Employee mistakes
// web page view.
app.get (
"/employee-mistakes", (_, res) => (
res.sendFile (
"./sources/features/get_mistakes/employee_mistakes.html",
options
)
)
);
// Running contracts
// operation.
app.get (
"/run-contracts", (_, res) => (
controller.get_running_contracts (
result => res.send (result)
)
)
);
// Expired contracts
// operation.
app.get (
"/exp-contracts", (_, res) => (
controller.get_expired_contracts (
result => res.send (result)
)
)
);
// Bad employees
// operation.
app.get (
"/bads-employees", (_, res) => (
controller.get_bad_employees (
result => res.send (result)
)
)
);
// Save contract
// operation.
app.post (
"/save-contract", (req, res) => (
controller.save_contract (
req.body, result => res.send (
result
)
)
)
);
// Stop contract
// operation.
app.post (
"/stp-contract", (req, res) => (
controller.stop_contract (
req.body, result => res.send (
result
)
)
)
);
// Save mistake
// operation.
app.post (
"/save-mistake", (req, res) => (
controller.save_mistake (
req.body, result => res.send (
result
)
)
)
);
// Change contract
// operation.
app.post (
"/change-contract", (req, res) => (
controller.override_contract (
req.body, result => res.send (
result
)
)
)
);
// Employee mistakes
// operation.
app.post (
"/emp-mistakes", (req, res) => (
controller.get_employee_mistakes (
req.body, result => res.send (
result
)
)
)
);
// Sign up operation.
app.post (
"/sign-up", (req, res) => (
controller.sign_up (
req.body, result => res.send (
result
)
)
)
);
// Sign in operation.
app.post (
"/sign-in", (req, res) => (
controller.sign_in (
req.body, result => res.send (
result
)
)
)
);
// For mail sender
// operation.
app.post (
"/send-gmail", (req, res) => (
controller.send_gmail (
req.body, result => res.send (
result
)
)
)
);
// Starts the server.
app.listen (port, err => {
// Whether an error is thrown.
if (err) {
// Displays this error message.
console.error ("Server Error: ", err);
// Otherwise.
} else {
// Makes a warn about server starting.
console.log (
"Server started at port: ", port
);
}
});