@xenterprises/fastify-xconfig 0.0.1
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/package.json +25 -0
- package/server/app.js +15 -0
- package/src/xConfig.js +10 -0
- package/test/index.js +17 -0
- package/tsconfig.json +16 -0
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xenterprises/fastify-xconfig",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "Fastify configuration plugin for setting up middleware, services, and route handling.",
|
|
6
|
+
"main": "src/xConfig.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "fastify start -l info server/app.js",
|
|
9
|
+
"dev": "fastify start -w -l info -P server/app.js",
|
|
10
|
+
"test": "node --test test/**/*.test.js"
|
|
11
|
+
},
|
|
12
|
+
"author": "Tim Mushen",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^22.7.4",
|
|
16
|
+
"c8": "^9.0.0",
|
|
17
|
+
"fastify": "^4.28.1",
|
|
18
|
+
"fastify-plugin": "^4.0.0",
|
|
19
|
+
"fastify-tsconfig": "^2.0.0",
|
|
20
|
+
"typescript": "^5.6.3"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@fastify/autoload": "^6.0.2"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/server/app.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// server/app.js
|
|
2
|
+
import Fastify from 'fastify';
|
|
3
|
+
import xConfig from '../src/xConfig.js'; // Import your plugin correctly
|
|
4
|
+
|
|
5
|
+
const fastify = Fastify();
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export default async function (fastify, opts) {
|
|
9
|
+
fastify.register(xConfig); // Register the default export, which should be a function
|
|
10
|
+
fastify.get('/', async (request, reply) => {
|
|
11
|
+
console.log(fastify.xEcho())
|
|
12
|
+
return { status: fastify.xEcho() }
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
};
|
package/src/xConfig.js
ADDED
package/test/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// test.js
|
|
2
|
+
const fastify = require('fastify')();
|
|
3
|
+
const myPlugin = require('../src/xConfig');
|
|
4
|
+
|
|
5
|
+
fastify.register(myPlugin);
|
|
6
|
+
|
|
7
|
+
fastify.get('/', async (request, reply) => {
|
|
8
|
+
return { message: fastify.myPluginMethod() };
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
fastify.listen(3000, (err, address) => {
|
|
12
|
+
if (err) {
|
|
13
|
+
console.error(err);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
console.log(`Server running at ${address}`);
|
|
17
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"declaration": true, // Generates .d.ts files for types
|
|
6
|
+
"outDir": "./dist", // Output directory for compiled files
|
|
7
|
+
"strict": true, // Enable all strict type-checking options
|
|
8
|
+
"moduleResolution": "node", // Proper module resolution
|
|
9
|
+
"esModuleInterop": true, // Allows default imports from CJS modules
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"sourceMap": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*"], // Specifies files to include for compilation
|
|
15
|
+
"exclude": ["node_modules", "dist"]
|
|
16
|
+
}
|