Skip to content

Commit 0f0bcde

Browse files
authored
Merge pull request #35 from shaunwarman/fix-csp
fix: csp config and minor refactor
2 parents 874a6f6 + 3291dab commit 0f0bcde

20 files changed

+830
-275
lines changed

.babelrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
2+
"compact": false,
23
"presets": [
34
[
45
"@babel/env", {
56
"debug": true,
6-
"useBuiltIns": "usage",
7+
"forceAllTransforms": true,
8+
"modules": false,
79
"targets": {
8-
"browsers": "extends @ladjs/browserslist-config"
10+
"browsers": [ "extends @ladjs/browserslist-config" ]
911
}
1012
}
1113
]

.gitattributes

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,196 @@
1+
# https://gist.github.com/niftylettuce/c56e1786b32c42cb697b7fa2a6b5c847
12
* text=auto
3+
4+
###### Git
5+
.gitattributes text
6+
.gitignore text
7+
.gitconfig text
8+
.gitmodules text
9+
10+
##### Windows
11+
*.bat text eol=crlf
12+
*.exe binary
13+
*.dll binary
14+
15+
##### Linux
16+
*.sh text eol=lf
17+
*.so binary
18+
19+
##### Global
20+
# Documents
21+
*.sql text
22+
*.md text
23+
*.adoc text
24+
*.textile text
25+
*.mustache text
26+
*.csv text
27+
*.tab text
28+
*.tsv text
29+
*.coffee text
30+
*.css text
31+
*.htm text
32+
*.html text
33+
*.xhtml text
34+
*.inc text
35+
*.js text
36+
*.jsx text
37+
*.less text
38+
*.od text
39+
*.onlydata text
40+
*.sass text
41+
*.scm text
42+
*.log text
43+
*.properties text
44+
*.scss text
45+
*.styl text
46+
*.tag text
47+
*.ts text
48+
*.tsx text
49+
*.dockerignore text
50+
Dockerfile text
51+
*.markdown text
52+
*.mdwn text
53+
*.mdown text
54+
*.mkd text
55+
*.mkdn text
56+
*.mdtxt text
57+
*.mdtext text
58+
*.txt text
59+
AUTHORS text
60+
CHANGELOG text
61+
CHANGES text
62+
CONTRIBUTING text
63+
COPYING text
64+
copyright text
65+
*COPYRIGHT* text
66+
INSTALL text
67+
license text
68+
LICENSE text
69+
NEWS text
70+
readme text
71+
*README* text
72+
TODO text
73+
# Configuration
74+
*.cnf text
75+
*.cfg text
76+
*.conf text
77+
*.config text
78+
*.ini text
79+
*.json text
80+
*.xml text
81+
*.bowerrc text
82+
.browserslistrc text
83+
.editorconfig text
84+
*.npmignore text
85+
*.yaml text
86+
*.yml text
87+
browserslist text
88+
Makefile text
89+
makefile text
90+
Procfile text
91+
.slugignore text
92+
# Linters
93+
.csslintrc text
94+
.eslintrc text
95+
.htmlhintrc text
96+
.jscsrc text
97+
.jshintrc text
98+
.jshintignore text
99+
.stylelintrc text
100+
# Video
101+
*.3gpp binary
102+
*.3gp binary
103+
*.as binary
104+
*.asf binary
105+
*.asx binary
106+
*.fla binary
107+
*.flv binary
108+
*.m4v binary
109+
*.mng binary
110+
*.mov binary
111+
*.mp4 binary
112+
*.mpeg binary
113+
*.mpg binary
114+
*.ogv binary
115+
*.swc binary
116+
*.swf binary
117+
*.webm binary
118+
# Audio
119+
*.kar binary
120+
*.m4a binary
121+
*.mid binary
122+
*.midi binary
123+
*.mp3 binary
124+
*.ogg binary
125+
*.ra binary
126+
# Graphics
127+
*.png binary
128+
*.jpg binary
129+
*.jpeg binary
130+
*.gif binary
131+
*.tif binary
132+
*.tiff binary
133+
*.ico binary
134+
*.eps binary
135+
*.ai binary
136+
*.bmp binary
137+
*.jng binary
138+
*.jp2 binary
139+
*.jpx binary
140+
*.jxr binary
141+
*.pdf binary
142+
*.psb binary
143+
*.psd binary
144+
*.svg text
145+
*.svgz binary
146+
*.wbmp binary
147+
*.webp binary
148+
# Archives
149+
*.7z binary
150+
*.gz binary
151+
*.jar binary
152+
*.rar binary
153+
*.tar binary
154+
*.zip binary
155+
# Fonts
156+
*.ttf binary
157+
*.eot binary
158+
*.otf binary
159+
*.woff binary
160+
*.woff2 binary
161+
# Executables
162+
*.pyc binary
163+
# Objects
164+
*.o binary
165+
166+
##### IDE/Editor
167+
# Visual Studio
168+
*.sln text eol=crlf
169+
*.csproj text eol=crlf
170+
*.vbproj text eol=crlf
171+
*.vcxproj text eol=crlf
172+
*.vcproj text eol=crlf
173+
*.dbproj text eol=crlf
174+
*.fsproj text eol=crlf
175+
*.lsproj text eol=crlf
176+
*.wixproj text eol=crlf
177+
*.modelproj text eol=crlf
178+
*.sqlproj text eol=crlf
179+
*.wmaproj text eol=crlf
180+
*.xproj text eol=crlf
181+
*.props text eol=crlf
182+
*.filters text eol=crlf
183+
*.vcxitems text eol=crlf
184+
# Eclipse
185+
*.project text
186+
*.classpath text
187+
*.prefs
188+
189+
##### Language
190+
# Java
191+
*.java text
192+
*.jsp text
193+
*.jspf text
194+
*.jspx text
195+
*.class binary
196+
*.war binary

api.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@ const _ = require('lodash');
55
const ip = require('ip');
66

77
const config = require('./config');
8-
const routes = require('./routes');
9-
const i18n = require('./helpers/i18n');
108
const logger = require('./helpers/logger');
11-
const passport = require('./helpers/passport');
129

13-
const api = new API({
14-
routes: routes.api,
15-
logger,
16-
i18n,
17-
passport
18-
});
10+
const apiConfig = require('./config/api');
11+
const api = new API(apiConfig);
1912

2013
if (!module.parent) {
2114
const mongoose = new Mongoose(

app/views/layout.pug

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ html(lang=locale).h-100
1616
link(rel="alternate", href=`${config.urls.web}/${language.locale}${ctx.pathWithoutLocale}`, hreflang=language.locale)
1717

1818
//- generated with https://realfavicongenerator.net
19-
link(rel="apple-touch-icon", sizes="152x152", href=manifest('img/apple-touch-icon.png'))
20-
link(rel="icon", type="image/png", href=manifest('img/favicon-32x32.png'), sizes="32x32")
21-
link(rel="icon", type="image/png", href=manifest('img/favicon-16x16.png'), sizes="16x16")
22-
link(rel="manifest", href="/manifest.json")
23-
24-
//- add mask-icon
25-
//- <https://goo.gl/PMBfKu>
26-
//- link(rel="mask-icon", href=manifest('img/safari-pinned-tab.svg'), color=config.appColor)
19+
link(rel="apple-touch-icon", sizes="152x152", href=manifest('img/apple-touch-icon.png'), integrity=manifest('img/apple-touch-icon.png', 'integrity'), crossorigin='anonymous')
20+
link(rel="icon", type="image/png", href=manifest('img/favicon-32x32.png'), sizes="32x32", integrity=manifest('img/favicon-32x32.png', 'integrity'), crossorigin='anonymous')
21+
link(rel="icon", type="image/png", href=manifest('img/favicon-16x16.png'), sizes="16x16", integrity=manifest('img/favicon-16x16.png', 'integrity'), crossorigin='anonymous')
22+
link(rel="manifest", href=manifest('site.webmanifest'), integrity=manifest('site.webmanifest', 'integrity'), crossorigin='anonymous')
23+
link(rel="mask-icon", href=manifest('img/safari-pinned-tab.svg'), integrity=manifest('img/safari-pinned-tab.svg', 'integrity'), color=config.appColor, crossorigin='anonymous')
2724
meta(name="apple-mobile-web-app-title", content=config.appName)
2825
meta(name="application-name", content=config.appName)
2926
meta(name="msapplication-TileColor", content=config.appColor)
30-
meta(name="theme-color", content=config.appColor)
27+
meta(name="theme-color", content="#ffffff")
3128

3229
//- csrf token
3330
meta(name="csrf-token", content=ctx.csrf)
@@ -36,7 +33,7 @@ html(lang=locale).h-100
3633

3734
//- add opengraph tags to your structured data pages
3835
block opengraph
39-
link(rel='image_src', type='image/png', href=manifest('img/social.png'))
36+
link(rel='image_src', type='image/png', href=manifest('img/social.png'), integrity=manifest('img/social.png', 'integrity'), crossorigin='anonymous')
4037
meta(property='og:title', content=meta.title)
4138
meta(property='og:url', content=`${config.urls.web}${ctx.pathWithoutLocale}`)
4239
meta(property='og:description', content=meta.description)
@@ -49,12 +46,26 @@ html(lang=locale).h-100
4946

5047
//- css file
5148
block stylesheets
52-
if config.env === 'production'
53-
link(rel="stylesheet", href=manifest('css/app.css') integrity=manifest('css/app.css', 'integrity'), crossorigin="anonymous")
54-
else
55-
link(rel="stylesheet", href=manifest('css/app.css'))
56-
57-
body(role='document', class=['/register', '/login', config.verifyRoute].includes(ctx.pathWithoutLocale) ? 'pt-0' : '').d-flex.flex-column.h-100
49+
link(rel="stylesheet", href=manifest('css/app.css'), integrity=manifest('css/app.css', 'integrity'), crossorigin='anonymous')
50+
51+
//- preload and prefetch content
52+
//- <https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content>
53+
//- <https://developers.google.com/speed/pagespeed/insights/>
54+
block preload
55+
each asset in [ 'fonts/fa-brands-400.woff', 'fonts/fa-solid-900.woff' ]
56+
//- integrity attribute not currently supported
57+
//- <https://crbug.com/981419>
58+
link(rel='preload', href=manifest(asset), as='font', crossorigin='anonymous')
59+
60+
block prefetch
61+
each asset in ['img/github-logo.svg', 'img/google-logo.svg']
62+
link(rel='prefetch', href=manifest(asset), as='image', crossorigin='anonymous')
63+
each asset in [ 'fonts/fa-brands-400.ttf', 'fonts/fa-solid-900.ttf' ]
64+
//- integrity attribute not currently supported
65+
//- <https://crbug.com/981419>
66+
link(rel='prefetch', href=manifest(asset), as='font', crossorigin='anonymous')
67+
68+
body(role='document').d-flex.flex-column.min-h-100
5869

5970
//- spinner
6071
block spinner
@@ -65,13 +76,14 @@ html(lang=locale).h-100
6576
include _nav
6677

6778
//- body
68-
main(role='main').flex-shrink-0
69-
block body
79+
main(role='main').flex-grow-1.d-flex.flex-column.flex-grow-1
80+
block body
7081

7182
//- footer
7283
block footer
7384
include _footer
7485

86+
//- scripts
7587
block scripts
7688
//- flash messaging (with koa-better-flash and sweetalert2)
7789
script.
@@ -122,11 +134,6 @@ html(lang=locale).h-100
122134
id: "#{ctx.sessionId}"
123135
};
124136

125-
//- factor bundle (common shared assets across all files)
126-
script(src=manifest('js/factor-bundle.js') integrity=manifest('js/factor-bundle.js', 'integrity') crossorigin="anonymous")
127-
128-
//- uncaught (handles errors, similar to TraceKit but with CabinJS + StackTrace.JS)
129-
script(src=manifest('js/uncaught.js') integrity=manifest('js/uncaught.js', 'integrity') crossorigin="anonymous")
130-
131-
//- scripts
132-
script(src=manifest('js/core.js') integrity=manifest('js/core.js', 'integrity') crossorigin="anonymous")
137+
//- build
138+
if !isBot(ctx.get('User-Agent'))
139+
script(async, src=manifest('js/build.js'), integrity=manifest('js/build.js', 'integrity'), crossorigin='anonymous')

assets/css/_custom.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// https://github.com/twbs/bootstrap/issues/24374
2+
.min-vh-80 {
3+
min-height: 80vh !important;
4+
}
5+
.min-h-100 {
6+
min-height: 100%;
7+
}
8+
9+
body {
10+
padding-top: 77px;
11+
text-rendering: optimizeLegibility;
12+
font-smoothing: antialiased;
13+
}
14+
115
.text-decoration-underline {
216
text-decoration: underline !important;
317
}

assets/css/_variables.scss

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
// TODO: eventually host ourselves
2-
$fa-font-path: "//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/webfonts" !default;
1+
$fa-font-path: "../fonts" !default;
2+
$fa-font-display: "swap" !default;
33

4-
// custom fonts using google webfont loader
5-
// with fonts defined in `assets/js/core.js`
6-
$font-family-sans-serif: 'Source Sans Pro', '-apple-system', BlinkMacSystemFont,
7-
'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !default;
4+
$font-family-sans-serif: '-apple-system', BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !default;
85

9-
$font-family-serif: Georgia, 'Times New Roman', Times, serif !default;
10-
$font-family-monospace: 'Source Code Pro', Menlo, Monaco, Consolas,
11-
'Liberation Mono', 'Courier New', monospace !default;
6+
$font-family-monospace: 'Inconsolata', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace !default;
127

138
$font-family-base: $font-family-sans-serif !default;
14-
$headings-font-family: 'Bitter', $font-family-sans-serif;
9+
10+
$headings-font-family: 'Poppins', $font-family-sans-serif;
11+
12+
$blue: #20C1ED !default;
13+
$cyan: #9DE5F9 !default;
14+
$green: #8CC63F !default;
15+
$yiq-contrasted-threshold: 200 !default;
16+
17+
$enable-responsive-font-sizes: true !default;

0 commit comments

Comments
 (0)