@quasar/render-ssr-error 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  import { readFileSync } from 'node:fs'
3
2
 
4
3
  import { getErrorDetails } from './error-details.js'
@@ -15,8 +14,19 @@ function readFile (target) {
15
14
  const before = readFile('before')
16
15
  const after = readFile('after')
17
16
 
18
- export default function renderSSRError ({ err, req, res, projectRootFolder }) {
17
+ /**
18
+ * @param {{
19
+ * err: Error;
20
+ * req: import('node:http').IncomingMessage | import('node:http2').Http2ServerRequest;
21
+ * res: import('node:http').ServerResponse | import('node:http2').Http2ServerResponse;
22
+ * projectRootFolder?: string;
23
+ * }} params
24
+ */
25
+ export default function renderSSRError ({ err, req, res, projectRootFolder = process.cwd() }) {
19
26
  const data = {
27
+ project: {
28
+ rootFolder: projectRootFolder,
29
+ },
20
30
  error: getErrorDetails(err),
21
31
  stack: getStack(err, projectRootFolder),
22
32
  env: getEnv(req)
@@ -27,7 +37,13 @@ export default function renderSSRError ({ err, req, res, projectRootFolder }) {
27
37
  // new URL('./data.json', import.meta.url), JSON.stringify(data, null, 2), 'utf8'
28
38
  // )
29
39
 
30
- res.status(500).send(
40
+ res.writeHead(500, {
41
+ 'Content-Type': 'text/html; charset=utf-8',
42
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
43
+ Pragma: 'no-cache',
44
+ Expires: '0'
45
+ })
46
+ res.end(
31
47
  before
32
48
  + JSON.stringify(data).replace(/<\/script>/g, '<\\/script>')
33
49
  + after
package/src/stack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync } from 'node:fs'
2
- import { join } from 'node:path'
2
+ import { join, relative } from 'node:path'
3
3
  import { parse } from 'stack-trace'
4
4
 
5
5
  function getFilename (filename) {
@@ -17,6 +17,13 @@ function getFilename (filename) {
17
17
  return nodeFilename
18
18
  }
19
19
  }
20
+
21
+ if (process.env.FNM_DIR && process.versions.node) {
22
+ const nodeFilename = join(process.env.FNM_DIR, 'src/node-versions/v' + process.versions.node, 'installation/lib', filename)
23
+ if (existsSync(nodeFilename)) {
24
+ return nodeFilename
25
+ }
26
+ }
20
27
  }
21
28
 
22
29
  function getSource (entry) {
@@ -59,14 +66,14 @@ function getSource (entry) {
59
66
  }
60
67
  }
61
68
 
62
- export function getStack (err) {
69
+ export function getStack (err, projectRootFolder) {
63
70
  const trace = parse(err)
64
71
 
65
72
  return trace.map(entry => {
66
73
  const { fileName, sourceCode } = getSource(entry)
67
74
 
68
75
  return {
69
- fileName,
76
+ fileName: relative(projectRootFolder, fileName),
70
77
  sourceCode,
71
78
  functionName: entry.getTypeName() || entry.getFunctionName(),
72
79
  methodName: `${ entry.isConstructor() ? 'new ' : '' }${ entry.getMethodName() || '<anonymous>' }`,
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- /src-ui/dist
2
- /src-ui/.quasar
3
- /node_modules
package/.eslintrc.cjs DELETED
@@ -1,70 +0,0 @@
1
-
2
- module.exports = {
3
- // https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
4
- // This option interrupts the configuration hierarchy at this file
5
- // Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
6
- root: true,
7
-
8
- parserOptions: {
9
- ecmaVersion: 'latest',
10
- sourceType: 'module'
11
- },
12
-
13
- env: {
14
- node: true,
15
- browser: true,
16
- 'vue/setup-compiler-macros': true
17
- },
18
-
19
- // Rules order is important, please avoid shuffling them
20
- extends: [
21
- 'eslint:recommended',
22
- 'plugin:vue/vue3-essential', // Priority A: Essential (Error Prevention)
23
- 'standard'
24
- ],
25
-
26
- plugins: [
27
- // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files
28
- // required to lint *.vue files
29
- 'vue'
30
- ],
31
-
32
- // add your custom rules here
33
- rules: {
34
- 'brace-style': [ 2, 'stroustrup', { allowSingleLine: true } ],
35
- 'prefer-const': 2,
36
- 'prefer-promise-reject-errors': 'off',
37
- 'multiline-ternary': 'off',
38
- 'no-prototype-builtins': 'off',
39
- 'no-case-declarations': 'off',
40
- 'generator-star-spacing': 'off',
41
- 'arrow-parens': 'off',
42
- 'object-property-newline': 'off',
43
- 'one-var': 'off',
44
- 'no-void': 'off',
45
- 'no-lone-blocks': 'error',
46
- 'no-unused-expressions': [ 'error', { allowShortCircuit: true } ],
47
- 'no-useless-concat': 'error',
48
- 'no-useless-return': 'error',
49
- 'no-unneeded-ternary': 'error',
50
- 'no-confusing-arrow': [ 'error', { allowParens: true } ],
51
- 'operator-linebreak': [ 'error', 'before' ],
52
-
53
- 'array-bracket-spacing': [ 'error', 'always' ],
54
- 'object-curly-spacing': [ 'error', 'always' ],
55
- 'computed-property-spacing': [ 'error', 'always' ],
56
- 'template-curly-spacing': [ 'error', 'always' ],
57
-
58
- 'import/first': 'off',
59
- 'import/named': 'error',
60
- 'import/namespace': 'error',
61
- 'import/default': 'error',
62
- 'import/export': 'error',
63
- 'import/extensions': 'off',
64
- 'import/no-unresolved': 'off',
65
- 'import/no-extraneous-dependencies': 'off',
66
-
67
- // allow debugger during development only
68
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
69
- }
70
- }