generated from corysanin/nodejs-web-template
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf43cdcf22 | |||
| 4dbf6a4ae6 | |||
| 617cffc052 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "madisonlinux",
|
"name": "madisonlinux",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "madisonlinux",
|
"name": "madisonlinux",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ejs": "3.1.10",
|
"ejs": "3.1.10",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "madisonlinux",
|
"name": "madisonlinux",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"description": "Website for upcoming Linux install party in Madison WI",
|
"description": "Website for upcoming Linux install party in Madison WI",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"web",
|
"web",
|
||||||
|
|||||||
17
src/Web.ts
17
src/Web.ts
@@ -3,7 +3,7 @@ import crypto from 'crypto';
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import bodyParser from 'body-parser';
|
import bodyParser from 'body-parser';
|
||||||
import type { Express } from 'express';
|
import type { Express } from 'express';
|
||||||
import { createEvent} from 'ics';
|
import { createEvent } from 'ics';
|
||||||
|
|
||||||
interface WebConfig {
|
interface WebConfig {
|
||||||
port?: number;
|
port?: number;
|
||||||
@@ -56,7 +56,13 @@ class Web {
|
|||||||
res.send('Healthy');
|
res.send('Healthy');
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/', (_, res) => {
|
app.get('/', (req, res) => {
|
||||||
|
if (req.query?.['utm_medium']) {
|
||||||
|
console.log(`${req.query['utm_medium']} | ${req.headers?.['user-agent']}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log(req.headers?.['user-agent']);
|
||||||
|
}
|
||||||
res.render('index', {
|
res.render('index', {
|
||||||
page: {
|
page: {
|
||||||
title: 'Madison End of 10 Install Party',
|
title: 'Madison End of 10 Install Party',
|
||||||
@@ -93,7 +99,7 @@ class Web {
|
|||||||
organizer: { name: 'Cory Sanin', email: 'endof10@cory.sanin.dev' },
|
organizer: { name: 'Cory Sanin', email: 'endof10@cory.sanin.dev' },
|
||||||
method: 'REQUEST'
|
method: 'REQUEST'
|
||||||
}, (err, s) => {
|
}, (err, s) => {
|
||||||
if(err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
res.status(500).send('something went wrong.');
|
res.status(500).send('something went wrong.');
|
||||||
return;
|
return;
|
||||||
@@ -105,6 +111,11 @@ class Web {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use(function (req, res, _) {
|
||||||
|
console.log(`404: ${req.url} requested by ${req.ip} "${req.headers['user-agent']}"`);
|
||||||
|
res.redirect('/');
|
||||||
|
});
|
||||||
|
|
||||||
this._webserver = this.app.listen(this.port, () => console.log(`madisonlinux is running on port ${this.port}`));
|
this._webserver = this.app.listen(this.port, () => console.log(`madisonlinux is running on port ${this.port}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user