Spaces:
Running
Running
run prettier
Browse files- app.js +12 -12
- plugins/fastify-view.js +7 -7
- plugins/sensible.js +6 -6
- plugins/support.js +6 -6
- routes/root.js +5 -5
app.js
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
|
2 |
|
3 |
-
const path = require(
|
4 |
-
const AutoLoad = require(
|
5 |
|
6 |
-
const options = {}
|
7 |
|
8 |
module.exports = async function (fastify, opts) {
|
9 |
fastify.register(AutoLoad, {
|
10 |
-
dir: path.join(__dirname,
|
11 |
-
options: Object.assign({}, opts)
|
12 |
-
})
|
13 |
|
14 |
fastify.register(AutoLoad, {
|
15 |
-
dir: path.join(__dirname,
|
16 |
-
options: Object.assign({}, opts)
|
17 |
-
})
|
18 |
-
}
|
19 |
|
20 |
-
module.exports.options = options
|
|
|
1 |
+
"use strict";
|
2 |
|
3 |
+
const path = require("node:path");
|
4 |
+
const AutoLoad = require("@fastify/autoload");
|
5 |
|
6 |
+
const options = {};
|
7 |
|
8 |
module.exports = async function (fastify, opts) {
|
9 |
fastify.register(AutoLoad, {
|
10 |
+
dir: path.join(__dirname, "plugins"),
|
11 |
+
options: Object.assign({}, opts),
|
12 |
+
});
|
13 |
|
14 |
fastify.register(AutoLoad, {
|
15 |
+
dir: path.join(__dirname, "routes"),
|
16 |
+
options: Object.assign({}, opts),
|
17 |
+
});
|
18 |
+
};
|
19 |
|
20 |
+
module.exports.options = options;
|
plugins/fastify-view.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
|
2 |
|
3 |
-
const fp = require(
|
4 |
|
5 |
/**
|
6 |
* This plugins adds some utilities to handle http errors
|
@@ -8,9 +8,9 @@ const fp = require('fastify-plugin')
|
|
8 |
* @see https://github.com/fastify/fastify-sensible
|
9 |
*/
|
10 |
module.exports = fp(async function (fastify, opts) {
|
11 |
-
fastify.register(require(
|
12 |
engine: {
|
13 |
-
ejs: require(
|
14 |
-
}
|
15 |
-
})
|
16 |
-
})
|
|
|
1 |
+
"use strict";
|
2 |
|
3 |
+
const fp = require("fastify-plugin");
|
4 |
|
5 |
/**
|
6 |
* This plugins adds some utilities to handle http errors
|
|
|
8 |
* @see https://github.com/fastify/fastify-sensible
|
9 |
*/
|
10 |
module.exports = fp(async function (fastify, opts) {
|
11 |
+
fastify.register(require("@fastify/view"), {
|
12 |
engine: {
|
13 |
+
ejs: require("ejs"),
|
14 |
+
},
|
15 |
+
});
|
16 |
+
});
|
plugins/sensible.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
|
2 |
|
3 |
-
const fp = require(
|
4 |
|
5 |
/**
|
6 |
* This plugins adds some utilities to handle http errors
|
@@ -8,7 +8,7 @@ const fp = require('fastify-plugin')
|
|
8 |
* @see https://github.com/fastify/fastify-sensible
|
9 |
*/
|
10 |
module.exports = fp(async function (fastify, opts) {
|
11 |
-
fastify.register(require(
|
12 |
-
errorHandler: false
|
13 |
-
})
|
14 |
-
})
|
|
|
1 |
+
"use strict";
|
2 |
|
3 |
+
const fp = require("fastify-plugin");
|
4 |
|
5 |
/**
|
6 |
* This plugins adds some utilities to handle http errors
|
|
|
8 |
* @see https://github.com/fastify/fastify-sensible
|
9 |
*/
|
10 |
module.exports = fp(async function (fastify, opts) {
|
11 |
+
fastify.register(require("@fastify/sensible"), {
|
12 |
+
errorHandler: false,
|
13 |
+
});
|
14 |
+
});
|
plugins/support.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
|
2 |
|
3 |
-
const fp = require(
|
4 |
|
5 |
// the use of fastify-plugin is required to be able
|
6 |
// to export the decorators to the outer scope
|
7 |
|
8 |
module.exports = fp(async function (fastify, opts) {
|
9 |
-
fastify.decorate(
|
10 |
-
return
|
11 |
-
})
|
12 |
-
})
|
|
|
1 |
+
"use strict";
|
2 |
|
3 |
+
const fp = require("fastify-plugin");
|
4 |
|
5 |
// the use of fastify-plugin is required to be able
|
6 |
// to export the decorators to the outer scope
|
7 |
|
8 |
module.exports = fp(async function (fastify, opts) {
|
9 |
+
fastify.decorate("someSupport", function () {
|
10 |
+
return "hugs";
|
11 |
+
});
|
12 |
+
});
|
routes/root.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
|
2 |
|
3 |
module.exports = async function (fastify, opts) {
|
4 |
-
fastify.get(
|
5 |
-
return { root: true }
|
6 |
-
})
|
7 |
-
}
|
|
|
1 |
+
"use strict";
|
2 |
|
3 |
module.exports = async function (fastify, opts) {
|
4 |
+
fastify.get("/", async function (request, reply) {
|
5 |
+
return { root: true };
|
6 |
+
});
|
7 |
+
};
|