Compare commits

...

10 Commits

Author SHA1 Message Date
E
dec522c914
Fix Docker and bio
Rename prepare step

Attempt docker fix

Docker fix

Fix bio and add pug prettier config

Fix spacing

Fix grammer
2024-04-29 17:21:32 +01:00
E
b3aae82a2a
Merge branch 'fix-docker-image' 2024-04-29 15:30:43 +01:00
E
140fa8fea0
Omit dev dependencies 2024-04-29 15:30:13 +01:00
E
eba987561e
Merge branch 'add-obsidian-graph' 2024-04-29 15:26:45 +01:00
E
e2115e041e
Added links on my about 2024-04-29 15:07:38 +01:00
E
dbd54804e6
Merge branch 'main' into add-obsidian-graph 2024-04-29 14:59:42 +01:00
E
7f2c5975da
Update about bio (#55)
* Update bio and remove CV link for privacy issues

* Update bio and remove CV link for privacy issues

* Format and fix linting issue

* Change bio
2024-04-29 14:58:42 +01:00
E
ee4d60d07a
Change CV to Obsidian 2024-04-29 14:56:19 +01:00
E
be151ade85
Add obsidian notes to repo 2024-04-29 14:52:09 +01:00
E
8449b30401
Add linting, formatting and pre-commit (#53)
* Add dev-dependancies

* Security update npm packages

* Force audit fix

* Add linting, formatting and precommit

* Format files
2024-04-29 13:21:31 +01:00
231 changed files with 9296 additions and 2105 deletions

15
.editorconfig Normal file
View File

@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
[pug.ts]
indent_size = 4

3
.eslintrc.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": ["prettier"]
}

2
.gitignore vendored
View File

@ -201,3 +201,5 @@ notes
public/stylesheets/style.css public/stylesheets/style.css
ngrok ngrok
.dccache .dccache
.DS_store

1
.husky/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
_

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

8
.prettierrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"semi": true,
"tabWidth": 2,
"singleQuote": true,
"jsxSingleQuote": true,
"plugins": ["prettier-plugin-tailwindcss", "@prettier/plugin-pug"]
}

View File

@ -1,4 +1,4 @@
FROM node:16-bullseye-slim FROM node:21-bullseye-slim
ENV IS_DOCKER=true ENV IS_DOCKER=true
ENV NODE_ENV=production ENV NODE_ENV=production

47
app.js
View File

@ -4,7 +4,7 @@ var path = require('path');
var cookieParser = require('cookie-parser'); var cookieParser = require('cookie-parser');
var mLogger = require('morgan'); var mLogger = require('morgan');
var logger = require('./config/winston'); var logger = require('./config/winston');
const helmet = require("helmet"); const helmet = require('helmet');
var indexRouter = require('./routes/index'); var indexRouter = require('./routes/index');
var aboutRouter = require('./routes/about'); var aboutRouter = require('./routes/about');
@ -12,7 +12,8 @@ var contactRouter = require('./routes/contact');
var app = express(); var app = express();
if (process.env.IS_DOCKER != 'true') app.set('trust proxy', 'loopback,uniquelocal'); if (process.env.IS_DOCKER != 'true')
app.set('trust proxy', 'loopback,uniquelocal');
app.disable('x-powered-by'); app.disable('x-powered-by');
// view engine setup // view engine setup
@ -20,7 +21,7 @@ app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug'); app.set('view engine', 'pug');
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
app.use(mLogger("common", { "stream": logger.stream })); app.use(mLogger('common', { stream: logger.stream }));
} else { } else {
app.use(mLogger('dev')); app.use(mLogger('dev'));
} }
@ -30,40 +31,62 @@ app.use(
helmet.contentSecurityPolicy({ helmet.contentSecurityPolicy({
directives: { directives: {
defaultSrc: ["'self'"], defaultSrc: ["'self'"],
scriptSrc: ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https://hcaptcha.com", "https://*.hcaptcha.com", "https://cdn.ravenjs.com/"], scriptSrc: [
imgSrc: ["'self'", "https://blog.pastel.codes", "https://static.ghost.org", "https://secure.gravatar.com"], "'self'",
styleSrc: ["'self'", "'unsafe-inline'", "https://hcaptcha.com", "https://*.hcaptcha.com"], "'unsafe-inline'",
fontSrc: ["'self'", "data:"], "'unsafe-eval'",
frameSrc: ["https://hcaptcha.com", "https://*.hcaptcha.com"], 'https://hcaptcha.com',
'https://*.hcaptcha.com',
'https://cdn.ravenjs.com/',
'https://cdnjs.cloudflare.com/',
'https://cdn.jsdelivr.net/',
'https://*.cloudfront.net/',
],
imgSrc: [
"'self'",
'https://blog.pastel.codes',
'https://static.ghost.org',
'https://secure.gravatar.com',
'data: ',
],
styleSrc: [
"'self'",
"'unsafe-inline'",
'https://hcaptcha.com',
'https://*.hcaptcha.com',
],
fontSrc: ["'self'", 'data:'],
frameSrc: ['https://hcaptcha.com', 'https://*.hcaptcha.com'],
objectSrc: ["'none'"], objectSrc: ["'none'"],
upgradeInsecureRequests: [], upgradeInsecureRequests: [],
}, },
}) })
); );
app.use(express.json()); app.use(express.json());
app.use(express.urlencoded({ extended: false })); app.use(express.urlencoded({ extended: false }));
app.use(cookieParser()); app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public')));
app.use('/obsidian', express.static(path.join(__dirname, 'obsidian')));
app.use('/', indexRouter); app.use('/', indexRouter);
app.use('/about', aboutRouter); app.use('/about', aboutRouter);
app.use('/contact', contactRouter); app.use('/contact', contactRouter);
// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function (req, res, next) {
next(createError(404)); next(createError(404));
}); });
// error handler // error handler
app.use(function(err, req, res, next) { app.use(function (err, req, res, _next) {
// set locals, only providing error in development // set locals, only providing error in development
res.locals.message = err.message; res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {}; res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page // render the error page
res.status(err.status || 500); res.status(err.status || 500);
res.render('error', { title: 'Error', description: "Error" }); res.render('error', { title: 'Error', description: 'Error' });
}); });
module.exports = app; module.exports = app;

View File

@ -59,9 +59,7 @@ function onError(error) {
throw error; throw error;
} }
var bind = typeof port === 'string' var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages // handle specific listen errors with friendly messages
switch (error.code) { switch (error.code) {
@ -84,8 +82,6 @@ function onError(error) {
function onListening() { function onListening() {
var addr = server.address(); var addr = server.address();
var bind = typeof addr === 'string' var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind); debug('Listening on ' + bind);
} }

View File

@ -10,21 +10,21 @@ var logger = new winston.createLogger({
json: true, json: true,
maxsize: 5242880, //5MB maxsize: 5242880, //5MB
maxFiles: 5, maxFiles: 5,
colorize: false colorize: false,
}), }),
new winston.transports.Console({ new winston.transports.Console({
level: 'debug', level: 'debug',
handleExceptions: true, handleExceptions: true,
json: false, json: false,
colorize: true colorize: true,
}) }),
], ],
exitOnError: false exitOnError: false,
}); });
logger.stream = { logger.stream = {
write: function(message, encoding){ write: function (message, _encoding) {
logger.info(message); logger.info(message);
} },
}; };
module.exports = logger module.exports = logger;

20
eslint.config.mjs Normal file
View File

@ -0,0 +1,20 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
export default [
{ files: ['**/*.js'], languageOptions: { sourceType: 'commonjs' } },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
{
rules: {
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
];

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More