Skip to content

Commit

Permalink
add enable param for clientViews, fix a lot of tests, update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Autre31415 committed Jan 15, 2025
1 parent dd712ba commit 1b55a2e
Show file tree
Hide file tree
Showing 27 changed files with 801 additions and 840 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,24 +403,23 @@ Resolves to:
- `port`: The port your app will run the HTTPS server on.
- Default: *[Number]* `43733`.
- `force`: Disallow unencrypted HTTP and route all traffic through HTTPS.
- Default: *[Boolean]* `false`.
- Default: *[Boolean]* `false`.
- `autoCert`: Will create self-signed HTTPS certificates in development mode as long as they don't already exist.
- Default: *[Boolean]* `true`.
- `authInfoPath`: *[Object]* Specify either the paths where the server certificate files can be found or set the appropriate parameters to be a PKCS#12-formatted string or certificate or key strings.
- Default: *[Object]* `undefined`.
- Default: *[Object]* `undefined`.
- Object members:
- `p12`: *[Object]* Parameter used when the server certificate/key is in PKCS#12 format.
- Default: *[Object]* `undefined`.
- Object members:
- `p12Path`: *[String]* Either the path to a PKCS#12-formatted file (e.g. a .p12 or .pfx file) or a PKCS#12-formatted string or buffer (e.g. the result of reading in the contents of a .p12 file).
- Default: `undefined`.
- `authCertAndKey`: *[Object]* Parameter used when the server certificate and key are in separate PEM-encoded files.
- Object members:
- `cert`: *[String]* Either the path to a PEM-encoded certificate file (e.g. .crt, .cer, etc.) or a PEM-encoded certificate string.
- Default: `undefined`.

- `key`: *[String]* Either the path to a PEM-encoded key file (e.g. .crt, .cer, etc.) or a PEM-encoded key string for the certificate given in `cert`.
- Default: `undefined`.
- `p12`: *[Object]* Parameter used when the server certificate/key is in PKCS#12 format.
- Default: *[Object]* `undefined`.
- Object members:
- `p12Path`: *[String]* Either the path to a PKCS#12-formatted file (e.g. a .p12 or .pfx file) or a PKCS#12-formatted string or buffer (e.g. the result of reading in the contents of a .p12 file).
- Default: `undefined`.
- `authCertAndKey`: *[Object]* Parameter used when the server certificate and key are in separate PEM-encoded files.
- Object members:
- `cert`: *[String]* Either the path to a PEM-encoded certificate file (e.g. .crt, .cer, etc.) or a PEM-encoded certificate string.
- Default: `undefined`.
- `key`: *[String]* Either the path to a PEM-encoded key file (e.g. .crt, .cer, etc.) or a PEM-encoded key string for the certificate given in `cert`.
- Default: `undefined`.
- `passphrase`: *[String]* Shared passphrase used for a single private key and/or a P12.
- Default: `undefined`.
- `requestCert`: *[Boolean]* Set whether to request a certificate from the client attempting to connect to the server to verify the client's identity.
Expand Down Expand Up @@ -633,6 +632,8 @@ Resolves to:

- `clientViews`: *[Object]* Allows you to expose view (template) file code to frontend JS for client-side templating.

- `enable`: *[Boolean]* Whether or not to bundle view files.

- `exposeAll`: *[Boolean]* Option to expose all templates.

- Default: *[Boolean]* `false`.
Expand Down
1 change: 1 addition & 0 deletions lib/defaults/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"versionedPublic": false,
"hostPublic": true,
"clientViews": {
"enable": false,
"allowlist": {},
"blocklist": [],
"output": "js",
Expand Down
3 changes: 3 additions & 0 deletions lib/sourceParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ module.exports = (params, appSchema) => {
default: defaults.hostPublic
},
clientViews: {
enable: {
default: defaults.clientViews.enable
},
allowlist: {
default: defaults.clientViews.allowlist
},
Expand Down
4 changes: 3 additions & 1 deletion lib/viewsBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ module.exports = async app => {
const appName = app.get('appName')
const viewsPath = app.get('viewsPath')
const viewEngine = app.get('view engine')
const { minify: willMinifyTemplates, exposeAll, allowlist, blocklist, defaultBundle } = app.get('params').clientViews
const { minify: willMinifyTemplates, exposeAll, enable, allowlist, blocklist, defaultBundle } = app.get('params').clientViews
const { onClientViewsProcess } = app.get('params')
let minifyOptions = app.get('params').clientViews.minifyOptions

if (!enable || !app.get('params').makeBuildArtifacts) return

// if the clientViews minifyOptions is empty, default back to the html.minifier options
if (Object.keys(minifyOptions).length === 0) minifyOptions = app.get('params').html.minifier.options

Expand Down
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@colors/colors": "1.6.0",
"@nodelib/fs.walk": "3.0.1",
"app-module-path": "2.2.0",
"better-sqlite3": "11.7.2",
"better-sqlite3": "11.8.0",
"better-sqlite3-session-store": "0.1.0",
"clean-css": "5.3.3",
"compression": "1.7.5",
Expand Down Expand Up @@ -62,7 +62,7 @@
"mocha": "11.0.1",
"prompts": "2.4.2",
"proxyquire": "2.1.3",
"sass": "1.83.1",
"sass": "1.83.4",
"sinon": "19.0.2",
"standard": "17.1.2",
"stylus": "0.64.0",
Expand Down
27 changes: 13 additions & 14 deletions test/bodyParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
const request = require('supertest')
const roosevelt = require('../roosevelt')

describe.skip('body-parser', () => {
before(done => {
describe('body-parser', () => {
before(async () => {
// spin up the roosevelt app
roosevelt({
const rooseveltApp = roosevelt({
makeBuildArtifacts: false,
port: 40000,
csrfProtection: false,
Expand All @@ -30,19 +30,18 @@ describe.skip('body-parser', () => {
json: {
limit: 10
}
},
onServerStart: app => {
// open up simple post route
app.route('/bodyParser').post((req, res) => {
res.send('done')
})
}
})

// bind app to test context
context.app = app
await rooseveltApp.startServer()

done()
}
}).startServer()
// open up simple post route
rooseveltApp.expressApp.route('/bodyParser').post((req, res) => {
res.send('done')
})

// bind app to test context
context.app = rooseveltApp.expressApp
})

after(done => {
Expand Down
2 changes: 1 addition & 1 deletion test/configAuditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const assert = require('assert')
const fs = require('fs-extra')
const path = require('path')

describe.skip('config auditor', () => {
describe('config auditor', () => {
const appDir = path.join(__dirname, 'app/configAudit')
let pkgJson
let configFile
Expand Down
Loading

0 comments on commit 1b55a2e

Please sign in to comment.