This repository was archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
82 lines (74 loc) · 3 KB
/
index.js
File metadata and controls
82 lines (74 loc) · 3 KB
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
var express = require('express')
var app = express()
app.set('port', (process.env.PORT || 5000))
app.use(express.static(__dirname + '/public'))
app.set('view engine', 'ejs')
app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'))
})
app.get('/403', function(req, res, next) {
// trigger a 403 error
var err = new Error('not allowed!');
err.status = 403;
next(err);
});
//Define Routes for the router to read
//Since I don't use a middleware for hand-off the complilation has to be perfect everytime
app.get('/', (req, res) => res.render('pages/index'))
app.get('/team', (req, res) => res.render('pages/team'))
app.get('/alphanode', (req, res) => res.render('pages/alphanode'))
app.get('/alumni', (req, res) => res.render('pages/alumni'))
app.get('/achievements', (req, res) => res.render('pages/achievements'))
app.get('/500', function(req, res, next) {
// trigger a generic (500) error
next(new Error('keyboard cat!'));
});
// Error handlers
//Check on a Darwin Compliant Terminal
// $ curl http://localhost:3000/notfound
// $ curl http://localhost:3000/notfound -H "Accept: application/json"
// $ curl http://localhost:3000/notfound -H "Accept: text/plain"
//Oopsie 404 error happens
app.use(function(req, res, next) {
res.status(404);
res.format({
html: function() {
res.render('404', { url: req.url })
},
json: function() {
res.json({ error: 'Not found' })
},
default: function() {
res.type('txt').send('Not found')
}
})
});
// error-handling middleware, take the same form
// as regular middleware, however they require an
// arity of 4, aka the signature (err, req, res, next).
// when connect has an error, it will invoke ONLY error-handling
// middleware.
/*
What is fucking confusing is the fact that pratyush doesnt even convert scss pages into css primarily using vue's render engine
to render this out which presents a problem because i only use ejs and express and hate using mark down due to arbitrary buffer
overflow issue thereby introducing a spectre attack vulnerability into a system which inherently never contacted the processor
itself instead uses c++ as a middleware to do so. Now in the latest revisions on node.js machine level code converted into higher
levels in the instance js and ts, however i either convert all of these files into regular css or somehow connect a middleware
and trick express servers to so
You think it's like but it's never like this
Never get or res.render a .scss page because it doesn't conform to the ejs standards
WTF PRATYUSH
JUST WTF
*/
app.use(function(err, req, res, next) {
// we may use properties of the error object
// here and next(err) appropriately, or if
// we possibly recovered from the error, simply next().
res.status(err.status || 500);
res.render('500', { error: err });
});
//start the server
if (!module.parent) {
app.listen(3000);
console.log('Express started on port 3000');
}