Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8372489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:26:42+00:00 2026-06-09T14:26:42+00:00

Below is a simple node.js using express var express = require(‘express’); var app =

  • 0

Below is a simple node.js using express

var express = require('express');
var app = express();

app.get('/', function(req, res){
  res.send('Hello World');
});

app.listen(3000);

I want to implement a plugin-in architecture, such as by default there is a folder called plugins, and they register by themselve when the node.js startup, I don’t need to modify the main server.js

an example a foo plugin, e.g.

PluginManager.register("init, function(app) {
    app.get('/foo', function(req, res){
        res.send('Hello from foo plugin');
    });
});

Then in my server.js, I would have something like

// TODO: Scan all scripts under the folder `plugins`
// TODO: Execute all the `init` hook before the app.listen
app.listen(3000);

My problem is my plugin codes are all asynchronous , there is no way to block before the app.listen(), do you have any idea for a better plugin-in architecture implementation?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:26:43+00:00Added an answer on June 9, 2026 at 2:26 pm

    Seems like whatever is loading the plugins would raise a callback like anything else.

    PluginManager.loadPlugins(function() { app.listen(3000); });
    

    This way the app wouldn’t start listening until the plugins are all loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am testing this simple code below and it works... $(document).ready( function() { $('.show-modal').click(
I have a node.js application using Express and Redis. My question is how do
I'm making a simple Facebook app that posts updates to the user's timeline using
I have defined simple grammar for parsing string and number using Treetop as below.
I have defined simple grammar for parsing string and number using Treetop as below.
I could submit a form and validate it using a simple anonymous function in
In the below sample XML, how to remove Entire B Node if E=13 using
Below just a simple race between 2 button in 2 threads, and this will
Consider the simple example below of implementing a method in an Enum. One problem
For a simple plot below, is there a way to make matplotlib populate the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.