-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
110 lines (99 loc) · 4.46 KB
/
index.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
// IMPORTS
require('dotenv').config();
const express = require('express');
const app = express();
const knex = require('knex');
const db = require('./connectors/db');
const bodyParser = require('body-parser');
// IMPORT AUTHENTICATION MIDDLEWARE
const authMiddleware = require('./middleware/auth');
const cors = require('cors');
app.use(cors());
// ALL ROUTES
//new 3 apis
const station = require('./routes/private/system_stations/station');
const zones = require('./routes/private/system_stations/zones');
const route = require('./routes/private/system_stations/route');
const signup_route = require('./routes/public/user_sign_up');
const login_route = require('./routes/public/user_login');
const logout_route = require('./routes/private/user_logout');
const refund_request_route = require('./routes/private/user_tickets/user_refund_request');
const user_forgot_password_route = require('./routes/public/forgot_pass/user_forgot_password');
const user_forgot_password_verify_route = require('./routes/public/forgot_pass/user_forgot_password_verify');
const user_forgot_password_new_password_route = require('./routes/public/forgot_pass/user_forgot_password_new_password');
const get_user_subscription_route = require('./routes/private/user_subscriptions/get_user_subscription');
const pay_for_subscription_route = require('./routes/private/user_subscriptions/pay_for_subscription');
const cancel_subscription_route = require('./routes/private/user_subscriptions/cancel_subscription');
const get_user_tickets = require('./routes/private/user_tickets/get_user_tickets');
const pay_for_ticket_route = require('./routes/private/user_tickets/pay_for_ticket');
const pay_for_ticket_by_sub_route = require('./routes/private/user_tickets/pay_for_ticket_by_Sub');
const get_user_transactions = require('./routes/private/user-transactions/get_transactions');
const rideStarted = require('./routes/private/user_rides/simulate_ride_start');
const rideEnded = require('./routes/private/user_rides/simulate_ride_end');
const user_senior_requests = require('./routes/private/user_requests/user_senior_request');
const admin_manage_senior_requests = require('./routes/private/admin_manage_requests/admin_manage_senior_requests');
const admin_manage_refund_requests = require('./routes/private/admin_manage_requests/admin_manage_refund_requests');
const get_senior_requests = require('./routes/private/admin_manage_requests/get_senior_requests');
const get_refund_requests = require('./routes/private/admin_manage_requests/get_refund_requests');
const superadmin_register_admin = require('./routes/private/superAdmin/superAdmin_register_admin');
const reset_password = require('./routes/private/reset_password/reset_password');
const subscription_stripe = require('./routes/private/stripe/subscription_stripe');
const ticket_stripe = require('./routes/private/stripe/ticket_stripe');
const cancel_stripe = require('./routes/private/stripe/cancel_stripe');
const get_current_user = require('./routes/public/get_cur_user');
const get_all_stations = require('./routes/public/getStations');
const check_price = require('./routes/public/check_price');
const get_all_users = require('./routes/private/get_all_users');
app.use('/health', (req, res) => {
return res.status(200).json({
status: 'OK',
});
});
// PUBLIC ROUTES
signup_route(app);
login_route(app);
user_forgot_password_route(app);
user_forgot_password_verify_route(app);
user_forgot_password_new_password_route(app);
get_current_user(app);
get_all_stations(app);
check_price(app);
app.use(authMiddleware);
// PRIVATE ROUTES
logout_route(app);
refund_request_route(app);
get_user_tickets(app);
get_user_subscription_route(app);
pay_for_subscription_route(app);
cancel_subscription_route(app);
pay_for_ticket_route(app);
pay_for_ticket_by_sub_route(app);
get_user_transactions(app);
rideStarted(app);
rideEnded(app);
user_senior_requests(app);
admin_manage_senior_requests(app);
admin_manage_refund_requests(app);
get_senior_requests(app);
get_refund_requests(app);
superadmin_register_admin(app);
rideStarted(app);
rideEnded(app);
station(app);
route(app);
zones(app);
reset_password(app);
subscription_stripe(app);
ticket_stripe(app);
cancel_stripe(app);
get_all_users(app);
// HANDLE IF WE DID NOT FIND THE ROUTE WE WERE LOOKING FOR
app.use(function (req, res, next) {
return res
.status(404)
.send('---------- ERROR COULD NOT FIND YOUR SPECIFIED ROUTE/PAGE -----------');
});
// START SERVER
app.listen(3000, () => {
console.log('Server is now listening at port 3000 on http://localhost:3000/');
});