Jump to content

Search the Community

Showing results for tags 'fastify'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General Discussion
    • Website Management and Coding
    • Technology and the Internet
    • Philosophy, Politics, and Science
    • Art and Entertainment
    • Other Discussion
  • HelioHost
    • Questions
    • Customer Service
    • How You Can Help
  • HelioNet
    • News
    • Contact HelioNet

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. I'm running a Fastify application on Johnny and have structured my project to keep routes separate for maintainability. Instead of defining all routes in app.js, I have a routes/ folder where each route is stored in its own file. For example, I have routes/apps.js, which looks like this: const knexConfig = require('../knexfile'); const knex = require('knex')(knexConfig.production); const authMiddleware = require('../middlewares/auth'); async function appRoutes(fastify, opts) { fastify.post('/addapps', { preHandler: authMiddleware }, async (request, reply) => { ... } module.exports = appRoutes; In the main app.js, I have this: const fastify = require('fastify')({ logger: true }); async function main() { try { await fastify.register(require('./routes/apps')); fastify.get('/', async (req, reply) => { return { message: 'Ok!' }; }); await fastify.listen({ port: 3000, host: '127.0.0.1' }); } catch (err) { fastify.log.error(err); process.exit(1); } } main(); The issue is that while the / route in app.js works just fine, any additional routes I place in routes/ do not work unless I manually define them inside app.js. I get the "not found" error. { "message": "Route GET:/addapps not found", "error": "Not Found", "statusCode": 404 } This defeats the purpose of splitting routes into separate files for maintainability. Is there a limitation on Johnny preventing Fastify from loading external routes properly or is it a config issue on my path? How can I ensure all routes inside routes/ are correctly recognized when using fastify.register()? I've attached a screenshot of my config. Thanks!
×
×
  • Create New...