Hi, when I try to start my API made with Fastify it gives me this error:
TypeScript
TypeError: userFunction is not a function
at execute (/usr/local/server/src/server.js:159:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async action (/usr/local/server/src/server.js:174:13)
at async /usr/local/server/src/server.js:10:9
Here is my package.json:
TypeScript
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"type": "module",
"scripts": {
"start": "node src/index",
"dev": "nodemon src/index"
},
"author": "",
"license": "ISC",
"dependencies": {
"@fastify/cors": "^8.5.0",
"@fastify/websocket": "^8.3.1",
"appwrite": "^14.0.0",
"dotenv": "^16.4.5",
"fastify": "^4.25.2",
"is-mobile": "^4.0.0",
"jsonwebtoken": "^9.0.2",
"mobile-device-detect": "^0.4.3",
"node-appwrite": "^12.0.1",
"node-steam-openid": "^1.2.3",
"nodemon": "^3.0.2",
"passport-steam": "^1.0.18",
"useragent": "^2.3.0"
}
}```
TL;DR
Developers are encountering a "TypeError: userFunction is not a function" error in their Fastify API. The issue may be related to incorrect usage of Fastify methods. Make sure all Fastify functions are properly defined and accessed.What’s your code look like?
@Kenny is my index.js:
TypeScript
import Fastify from "fastify";
import web from "./api/auth/web.js";
import app from "./api/auth/app.js";
import { config } from "dotenv";
config()
const fastify = Fastify({
logger: true,
});
fastify.register(web, { prefix: "/auth/web/" });
fastify.register(app, { prefix: "/auth/app/" });
try {
await fastify.listen({ host: "0.0.0.0", port: 1009 });
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
Recommended threads
- Hi Appwrite Support Team,My project has ...
Details: Project ID: 69a69f6f00113ed0e8e4 Region: SFO (sfo.cloud.appwrite.io) Error Response: Affected: ALL endpoints — Functions, Databases, Storage, Health, ...
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...