elm-pages 3.0.0-beta.16 → 3.0.0-beta.17
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/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/src/build.js +7 -7
- package/generator/src/cli.js +9 -6
- package/generator/src/dev-server.js +6 -6
- package/generator/src/render-test.js +1 -1
- package/generator/src/request-cache.js +5 -5
- package/package.json +1 -1
- package/src/BackendTask/{Port.elm → Custom.elm} +46 -46
- package/src/BackendTask/File.elm +1 -1
- package/src/BackendTask.elm +1 -1
- package/src/Pages/Internal/Platform/StaticResponses.elm +1 -1
|
Binary file
|
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 4015861069, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
Binary file
|
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 1374716823, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
package/generator/src/build.js
CHANGED
|
@@ -143,9 +143,9 @@ async function run(options) {
|
|
|
143
143
|
|
|
144
144
|
const portBackendTaskCompiled = esbuild
|
|
145
145
|
.build({
|
|
146
|
-
entryPoints: ["./
|
|
146
|
+
entryPoints: ["./custom-backend-task"],
|
|
147
147
|
platform: "node",
|
|
148
|
-
outfile: ".elm-pages/compiled-ports/
|
|
148
|
+
outfile: ".elm-pages/compiled-ports/custom-backend-task.js",
|
|
149
149
|
assetNames: "[name]-[hash]",
|
|
150
150
|
chunkNames: "chunks/[name]-[hash]",
|
|
151
151
|
outExtension: { ".js": ".js" },
|
|
@@ -161,11 +161,11 @@ async function run(options) {
|
|
|
161
161
|
})
|
|
162
162
|
.catch((error) => {
|
|
163
163
|
const portBackendTaskFileFound =
|
|
164
|
-
globby.sync("./
|
|
164
|
+
globby.sync("./custom-backend-task.*").length > 0;
|
|
165
165
|
if (portBackendTaskFileFound) {
|
|
166
|
-
// don't present error if there are no files matching
|
|
167
|
-
// if there are files matching
|
|
168
|
-
console.error("Failed to start
|
|
166
|
+
// don't present error if there are no files matching custom-backend-task
|
|
167
|
+
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
|
|
168
|
+
console.error("Failed to start custom-backend-task watcher", error);
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
// TODO extract common code for compiling ports file?
|
|
@@ -617,7 +617,7 @@ async function runAdapter(adaptFn, processedIndexTemplate) {
|
|
|
617
617
|
apiRoutePatterns: JSON.parse(
|
|
618
618
|
await fsPromises.readFile("./dist/api-patterns.json", "utf-8")
|
|
619
619
|
),
|
|
620
|
-
portsFilePath: "./.elm-pages/compiled-ports/
|
|
620
|
+
portsFilePath: "./.elm-pages/compiled-ports/custom-backend-task.js",
|
|
621
621
|
htmlTemplate: processedIndexTemplate,
|
|
622
622
|
});
|
|
623
623
|
console.log("Success - Adapter script complete");
|
package/generator/src/cli.js
CHANGED
|
@@ -131,9 +131,9 @@ async function main() {
|
|
|
131
131
|
|
|
132
132
|
const portBackendTaskCompiled = esbuild
|
|
133
133
|
.build({
|
|
134
|
-
entryPoints: ["./
|
|
134
|
+
entryPoints: ["./custom-backend-task"],
|
|
135
135
|
platform: "node",
|
|
136
|
-
outfile: ".elm-pages/compiled-ports/
|
|
136
|
+
outfile: ".elm-pages/compiled-ports/custom-backend-task.js",
|
|
137
137
|
assetNames: "[name]-[hash]",
|
|
138
138
|
chunkNames: "chunks/[name]-[hash]",
|
|
139
139
|
outExtension: { ".js": ".js" },
|
|
@@ -151,11 +151,14 @@ async function main() {
|
|
|
151
151
|
})
|
|
152
152
|
.catch((error) => {
|
|
153
153
|
const portBackendTaskFileFound =
|
|
154
|
-
globby.sync("./
|
|
154
|
+
globby.sync("./custom-backend-task.*").length > 0;
|
|
155
155
|
if (portBackendTaskFileFound) {
|
|
156
|
-
// don't present error if there are no files matching
|
|
157
|
-
// if there are files matching
|
|
158
|
-
console.error(
|
|
156
|
+
// don't present error if there are no files matching custom-backend-task
|
|
157
|
+
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
|
|
158
|
+
console.error(
|
|
159
|
+
"Failed to start custom-backend-task watcher",
|
|
160
|
+
error
|
|
161
|
+
);
|
|
159
162
|
}
|
|
160
163
|
});
|
|
161
164
|
const portsPath = await portBackendTaskCompiled;
|
|
@@ -140,7 +140,7 @@ async function start(options) {
|
|
|
140
140
|
);
|
|
141
141
|
esbuild
|
|
142
142
|
.build({
|
|
143
|
-
entryPoints: ["./
|
|
143
|
+
entryPoints: ["./custom-backend-task"],
|
|
144
144
|
platform: "node",
|
|
145
145
|
assetNames: "[name]-[hash]",
|
|
146
146
|
chunkNames: "chunks/[name]-[hash]",
|
|
@@ -171,15 +171,15 @@ async function start(options) {
|
|
|
171
171
|
],
|
|
172
172
|
})
|
|
173
173
|
.then((result) => {
|
|
174
|
-
console.log("Watching
|
|
174
|
+
console.log("Watching custom-backend-task...");
|
|
175
175
|
})
|
|
176
176
|
.catch((error) => {
|
|
177
177
|
const portBackendTaskFileFound =
|
|
178
|
-
globby.sync("./
|
|
178
|
+
globby.sync("./custom-backend-task.*").length > 0;
|
|
179
179
|
if (portBackendTaskFileFound) {
|
|
180
|
-
// don't present error if there are no files matching
|
|
181
|
-
// if there are files matching
|
|
182
|
-
console.error("Failed to start
|
|
180
|
+
// don't present error if there are no files matching custom-backend-task
|
|
181
|
+
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
|
|
182
|
+
console.error("Failed to start custom-backend-task watcher", error);
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
|
|
@@ -27,7 +27,7 @@ async function run({ pathname, serverRequest }) {
|
|
|
27
27
|
console.log("Compiling DONE");
|
|
28
28
|
|
|
29
29
|
const portsFilePath =
|
|
30
|
-
".elm-pages/compiled-ports/
|
|
30
|
+
".elm-pages/compiled-ports/custom-backend-task-FA2IJND6.js";
|
|
31
31
|
const mode = "dev-server";
|
|
32
32
|
|
|
33
33
|
const renderResult = await renderer.render(
|
|
@@ -43,21 +43,21 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
43
43
|
resolve({
|
|
44
44
|
kind: "response-json",
|
|
45
45
|
value: jsonResponse({
|
|
46
|
-
"elm-pages-internal-error": "
|
|
46
|
+
"elm-pages-internal-error": "CustomBackendTaskNotDefined",
|
|
47
47
|
}),
|
|
48
48
|
});
|
|
49
49
|
} else if (portBackendTaskImportError === "missing") {
|
|
50
50
|
resolve({
|
|
51
51
|
kind: "response-json",
|
|
52
52
|
value: jsonResponse({
|
|
53
|
-
"elm-pages-internal-error": "
|
|
53
|
+
"elm-pages-internal-error": "MissingCustomBackendTaskFile",
|
|
54
54
|
}),
|
|
55
55
|
});
|
|
56
56
|
} else {
|
|
57
57
|
resolve({
|
|
58
58
|
kind: "response-json",
|
|
59
59
|
value: jsonResponse({
|
|
60
|
-
"elm-pages-internal-error": "
|
|
60
|
+
"elm-pages-internal-error": "ErrorInCustomBackendTaskFile",
|
|
61
61
|
error:
|
|
62
62
|
(portBackendTaskImportError &&
|
|
63
63
|
portBackendTaskImportError.stack) ||
|
|
@@ -83,7 +83,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
83
83
|
resolve({
|
|
84
84
|
kind: "response-json",
|
|
85
85
|
value: jsonResponse({
|
|
86
|
-
"elm-pages-internal-error": "
|
|
86
|
+
"elm-pages-internal-error": "CustomBackendTaskException",
|
|
87
87
|
error: portCallError,
|
|
88
88
|
}),
|
|
89
89
|
});
|
|
@@ -92,7 +92,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
92
92
|
} catch (error) {
|
|
93
93
|
console.trace(error);
|
|
94
94
|
reject({
|
|
95
|
-
title: "BackendTask.
|
|
95
|
+
title: "BackendTask.Custom Error",
|
|
96
96
|
message: error.toString(),
|
|
97
97
|
});
|
|
98
98
|
}
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
module BackendTask.
|
|
2
|
-
(
|
|
1
|
+
module BackendTask.Custom exposing
|
|
2
|
+
( run
|
|
3
3
|
, Error(..)
|
|
4
4
|
)
|
|
5
5
|
|
|
6
6
|
{-| In a vanilla Elm application, ports let you either send or receive JSON data between your Elm application and the JavaScript context in the user's browser at runtime.
|
|
7
7
|
|
|
8
|
-
With `BackendTask.
|
|
8
|
+
With `BackendTask.Custom`, you send and receive JSON to JavaScript running in NodeJS. As with any `BackendTask`, Custom BackendTask's are either run at build-time (for pre-rendered routes) or at request-time (for server-rendered routes). See [`BackendTask`](BackendTask) for more about the
|
|
9
9
|
lifecycle of `BackendTask`'s.
|
|
10
10
|
|
|
11
11
|
This means that you can call shell scripts, run NPM packages that are installed, or anything else you could do with NodeJS to perform custom side-effects, get some data, or both.
|
|
12
12
|
|
|
13
|
-
A `BackendTask.
|
|
13
|
+
A `BackendTask.Custom` will call an async JavaScript function with the given name from the definition in a file called `custom-backend-task.js` in your project's root directory. The function receives the input JSON value, and the Decoder is used to decode the return value of the async function.
|
|
14
14
|
|
|
15
|
-
@docs
|
|
15
|
+
@docs run
|
|
16
16
|
|
|
17
|
-
Here is the Elm code and corresponding JavaScript definition for getting an environment variable (or an `FatalError BackendTask.
|
|
17
|
+
Here is the Elm code and corresponding JavaScript definition for getting an environment variable (or an `FatalError BackendTask.Custom.Error` if it isn't found). In this example,
|
|
18
18
|
we're using `BackendTask.allowFatal` to let the framework treat that as an unexpected exception, but we could also handle the possible failures of the `FatalError` (see [`FatalError`](FatalError)).
|
|
19
19
|
|
|
20
20
|
import BackendTask exposing (BackendTask)
|
|
21
|
-
import BackendTask.
|
|
21
|
+
import BackendTask.Custom
|
|
22
22
|
import Json.Encode
|
|
23
23
|
import OptimizedDecoder as Decode
|
|
24
24
|
|
|
25
25
|
data : BackendTask FatalError String
|
|
26
26
|
data =
|
|
27
|
-
BackendTask.
|
|
27
|
+
BackendTask.Custom.run "environmentVariable"
|
|
28
28
|
(Json.Encode.string "EDITOR")
|
|
29
29
|
Decode.string
|
|
30
30
|
|> BackendTask.allowFatal
|
|
@@ -32,7 +32,7 @@ we're using `BackendTask.allowFatal` to let the framework treat that as an unexp
|
|
|
32
32
|
-- will resolve to "VIM" if you run `EDITOR=vim elm-pages dev`
|
|
33
33
|
|
|
34
34
|
```javascript
|
|
35
|
-
//
|
|
35
|
+
// custom-backend-task.js
|
|
36
36
|
|
|
37
37
|
module.exports =
|
|
38
38
|
/**
|
|
@@ -60,37 +60,37 @@ ${Object.keys(process.env).join("\n")}
|
|
|
60
60
|
## Performance
|
|
61
61
|
|
|
62
62
|
As with any JavaScript or NodeJS code, avoid doing blocking IO operations. For example, avoid using `fs.readFileSync`, because blocking IO can slow down your elm-pages builds and dev server. `elm-pages` performances all `BackendTask`'s in parallel whenever possible.
|
|
63
|
-
So if you do `BackendTask.map2 Tuple.pair myHttpBackendTask
|
|
64
|
-
it will need to resolve them in sequence rather than in parallel, but it's still best to avoid blocking IO operations in your BackendTask
|
|
63
|
+
So if you do `BackendTask.map2 Tuple.pair myHttpBackendTask myCustomBackendTask`, it will resolve those two in parallel. NodeJS performs best when you take advantage of its ability to do non-blocking I/O (file reads, HTTP requests, etc.). If you use `BackendTask.andThen`,
|
|
64
|
+
it will need to resolve them in sequence rather than in parallel, but it's still best to avoid blocking IO operations in your Custom BackendTask definitions.
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
## Error Handling
|
|
68
68
|
|
|
69
|
-
There are a few different things that can go wrong when running a
|
|
69
|
+
There are a few different things that can go wrong when running a custom-backend-task. These possible errors are captured in the `BackendTask.Custom.Error` type.
|
|
70
70
|
|
|
71
71
|
@docs Error
|
|
72
72
|
|
|
73
|
-
Any time you throw a JavaScript exception from a BackendTask.
|
|
74
|
-
to handle possible errors, but you can throw a JSON value and handle it in Elm in the `
|
|
73
|
+
Any time you throw a JavaScript exception from a BackendTask.Custom definition, it will give you a `CustomBackendTaskException`. It's usually easier to add a `try`/`catch` in your JavaScript code in `custom-backend-task.js`
|
|
74
|
+
to handle possible errors, but you can throw a JSON value and handle it in Elm in the `CustomBackendTaskException` call error.
|
|
75
75
|
|
|
76
76
|
-}
|
|
77
77
|
|
|
78
78
|
import BackendTask
|
|
79
79
|
import BackendTask.Http
|
|
80
80
|
import BackendTask.Internal.Request
|
|
81
|
-
import FatalError exposing (FatalError
|
|
81
|
+
import FatalError exposing (FatalError)
|
|
82
82
|
import Json.Decode as Decode exposing (Decoder)
|
|
83
83
|
import Json.Encode as Encode
|
|
84
84
|
import TerminalText
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
{-| -}
|
|
88
|
-
|
|
88
|
+
run :
|
|
89
89
|
String
|
|
90
90
|
-> Encode.Value
|
|
91
91
|
-> Decoder b
|
|
92
92
|
-> BackendTask.BackendTask { fatal : FatalError, recoverable : Error } b
|
|
93
|
-
|
|
93
|
+
run portName input decoder =
|
|
94
94
|
BackendTask.Internal.Request.request
|
|
95
95
|
{ name = "port"
|
|
96
96
|
, body =
|
|
@@ -104,17 +104,17 @@ get portName input decoder =
|
|
|
104
104
|
[ Decode.field "elm-pages-internal-error" Decode.string
|
|
105
105
|
|> Decode.andThen
|
|
106
106
|
(\errorKind ->
|
|
107
|
-
if errorKind == "
|
|
107
|
+
if errorKind == "CustomBackendTaskNotDefined" then
|
|
108
108
|
FatalError.recoverable
|
|
109
|
-
{ title = "
|
|
109
|
+
{ title = "Custom BackendTask Error"
|
|
110
110
|
, body =
|
|
111
|
-
[ TerminalText.text "Something went wrong in a call to BackendTask.
|
|
111
|
+
[ TerminalText.text "Something went wrong in a call to BackendTask.Custom.run. I expected to find a port named `"
|
|
112
112
|
, TerminalText.yellow portName
|
|
113
|
-
, TerminalText.text "` but I couldn't find it. Is the function exported in your
|
|
113
|
+
, TerminalText.text "` but I couldn't find it. Is the function exported in your custom-backend-task file?"
|
|
114
114
|
]
|
|
115
115
|
|> TerminalText.toString
|
|
116
116
|
}
|
|
117
|
-
(
|
|
117
|
+
(CustomBackendTaskNotDefined { name = portName })
|
|
118
118
|
|> Decode.succeed
|
|
119
119
|
|
|
120
120
|
else if errorKind == "ExportIsNotFunction" then
|
|
@@ -122,78 +122,78 @@ get portName input decoder =
|
|
|
122
122
|
|> Decode.maybe
|
|
123
123
|
|> Decode.map (Maybe.withDefault "")
|
|
124
124
|
|> Decode.map
|
|
125
|
-
(\
|
|
125
|
+
(\incorrectType ->
|
|
126
126
|
FatalError.recoverable
|
|
127
|
-
{ title = "
|
|
127
|
+
{ title = "Custom BackendTask Error"
|
|
128
128
|
, body =
|
|
129
|
-
[ TerminalText.text "Something went wrong in a call to BackendTask.
|
|
129
|
+
[ TerminalText.text "Something went wrong in a call to BackendTask.Custom.run. I found an export called `"
|
|
130
130
|
, TerminalText.yellow portName
|
|
131
131
|
, TerminalText.text "` but I expected its type to be function, but instead its type was: "
|
|
132
|
-
, TerminalText.red
|
|
132
|
+
, TerminalText.red incorrectType
|
|
133
133
|
]
|
|
134
134
|
|> TerminalText.toString
|
|
135
135
|
}
|
|
136
136
|
ExportIsNotFunction
|
|
137
137
|
)
|
|
138
138
|
|
|
139
|
-
else if errorKind == "
|
|
139
|
+
else if errorKind == "MissingCustomBackendTaskFile" then
|
|
140
140
|
FatalError.recoverable
|
|
141
|
-
{ title = "
|
|
141
|
+
{ title = "Custom BackendTask Error"
|
|
142
142
|
, body =
|
|
143
|
-
[ TerminalText.text "Something went wrong in a call to BackendTask.
|
|
143
|
+
[ TerminalText.text "Something went wrong in a call to BackendTask.Custom.run. I couldn't find your custom-backend-task file. Be sure to create a 'custom-backend-task.ts' or 'custom-backend-task.js' file."
|
|
144
144
|
]
|
|
145
145
|
|> TerminalText.toString
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
MissingCustomBackendTaskFile
|
|
148
148
|
|> Decode.succeed
|
|
149
149
|
|
|
150
|
-
else if errorKind == "
|
|
150
|
+
else if errorKind == "ErrorInCustomBackendTaskFile" then
|
|
151
151
|
Decode.field "error" Decode.string
|
|
152
152
|
|> Decode.maybe
|
|
153
153
|
|> Decode.map (Maybe.withDefault "")
|
|
154
154
|
|> Decode.map
|
|
155
155
|
(\errorMessage ->
|
|
156
156
|
FatalError.recoverable
|
|
157
|
-
{ title = "
|
|
157
|
+
{ title = "Custom BackendTask Error"
|
|
158
158
|
, body =
|
|
159
|
-
[ TerminalText.text "Something went wrong in a call to BackendTask.
|
|
159
|
+
[ TerminalText.text "Something went wrong in a call to BackendTask.Custom.run. I couldn't import the port definitions file, because of this exception:\n\n"
|
|
160
160
|
, TerminalText.red errorMessage
|
|
161
161
|
, TerminalText.text "\n\nAre there syntax errors or exceptions thrown during import?"
|
|
162
162
|
]
|
|
163
163
|
|> TerminalText.toString
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
ErrorInCustomBackendTaskFile
|
|
166
166
|
)
|
|
167
167
|
|
|
168
|
-
else if errorKind == "
|
|
168
|
+
else if errorKind == "CustomBackendTaskException" then
|
|
169
169
|
Decode.field "error" Decode.value
|
|
170
170
|
|> Decode.maybe
|
|
171
171
|
|> Decode.map (Maybe.withDefault Encode.null)
|
|
172
172
|
|> Decode.map
|
|
173
173
|
(\portCallError ->
|
|
174
174
|
FatalError.recoverable
|
|
175
|
-
{ title = "
|
|
175
|
+
{ title = "Custom BackendTask Error"
|
|
176
176
|
, body =
|
|
177
|
-
[ TerminalText.text "Something went wrong in a call to BackendTask.
|
|
177
|
+
[ TerminalText.text "Something went wrong in a call to BackendTask.Custom.run. I was able to import the port definitions file, but when running it I encountered this exception:\n\n"
|
|
178
178
|
, TerminalText.red (Encode.encode 2 portCallError)
|
|
179
|
-
, TerminalText.text "\n\nYou could add a `try`/`catch` in your `
|
|
179
|
+
, TerminalText.text "\n\nYou could add a `try`/`catch` in your `custom-backend-task` JavaScript code to handle that error."
|
|
180
180
|
]
|
|
181
181
|
|> TerminalText.toString
|
|
182
182
|
}
|
|
183
|
-
(
|
|
183
|
+
(CustomBackendTaskException portCallError)
|
|
184
184
|
)
|
|
185
185
|
|
|
186
186
|
else
|
|
187
187
|
FatalError.recoverable
|
|
188
|
-
{ title = "
|
|
188
|
+
{ title = "Custom BackendTask Error"
|
|
189
189
|
, body =
|
|
190
|
-
[ TerminalText.text "Something went wrong in a call to BackendTask.
|
|
190
|
+
[ TerminalText.text "Something went wrong in a call to BackendTask.Custom.run. I expected to find a port named `"
|
|
191
191
|
, TerminalText.yellow portName
|
|
192
192
|
, TerminalText.text "`."
|
|
193
193
|
]
|
|
194
194
|
|> TerminalText.toString
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
ErrorInCustomBackendTaskFile
|
|
197
197
|
|> Decode.succeed
|
|
198
198
|
)
|
|
199
199
|
|> Decode.map Err
|
|
@@ -207,8 +207,8 @@ get portName input decoder =
|
|
|
207
207
|
{-| -}
|
|
208
208
|
type Error
|
|
209
209
|
= Error
|
|
210
|
-
|
|
|
211
|
-
|
|
|
212
|
-
|
|
|
213
|
-
|
|
|
210
|
+
| ErrorInCustomBackendTaskFile
|
|
211
|
+
| MissingCustomBackendTaskFile
|
|
212
|
+
| CustomBackendTaskNotDefined { name : String }
|
|
213
|
+
| CustomBackendTaskException Decode.Value
|
|
214
214
|
| ExportIsNotFunction
|
package/src/BackendTask/File.elm
CHANGED
package/src/BackendTask.elm
CHANGED
|
@@ -16,7 +16,7 @@ A `BackendTask` lets you pull in data from:
|
|
|
16
16
|
- Local files ([`BackendTask.File`](BackendTask-File))
|
|
17
17
|
- HTTP requests ([`BackendTask.Http`](BackendTask-Http))
|
|
18
18
|
- Globs, i.e. listing out local files based on a pattern like `content/*.txt` ([`BackendTask.Glob`](BackendTask-Glob))
|
|
19
|
-
- Ports, i.e. getting JSON data from running custom NodeJS, similar to a port in a vanilla Elm app except run at build-time in NodeJS, rather than at run-time in the browser ([`BackendTask.
|
|
19
|
+
- Ports, i.e. getting JSON data from running custom NodeJS, similar to a port in a vanilla Elm app except run at build-time in NodeJS, rather than at run-time in the browser ([`BackendTask.Custom`](BackendTask-Custom))
|
|
20
20
|
- Hardcoded data (`BackendTask.succeed "Hello!"`)
|
|
21
21
|
- Or any combination of the above, using `BackendTask.map2`, `BackendTask.andThen`, or other combining/continuing helpers from this module
|
|
22
22
|
|
|
@@ -2,7 +2,7 @@ module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), empty, ne
|
|
|
2
2
|
|
|
3
3
|
import BackendTask exposing (BackendTask)
|
|
4
4
|
import BuildError exposing (BuildError)
|
|
5
|
-
import FatalError exposing (FatalError
|
|
5
|
+
import FatalError exposing (FatalError)
|
|
6
6
|
import List.Extra
|
|
7
7
|
import Pages.Internal.FatalError
|
|
8
8
|
import Pages.StaticHttp.Request as HashRequest
|