express icon indicating copy to clipboard operation
express copied to clipboard

Creating a custom framework of express

Open RjManhas opened this issue 1 year ago • 4 comments

Hello i want to make a framework based off express like in the docs where theses frameworks do. link but how are they using express under the hood.

RjManhas avatar Jun 18 '23 11:06 RjManhas

maybe a more updated / better version of this example https://github.com/53js/express-server-app/tree/master

RjManhas avatar Jun 18 '23 11:06 RjManhas

just some extra info, basicly all i would want to do is get some options / config from the user before the server starts and then based off that, inject some routes / middleware and then functions into the app

RjManhas avatar Jun 18 '23 12:06 RjManhas

I fail to understand what you are triyng to do. Are you tring to write an express app? Do you want to contribute to express? Do you want to create your own fork of express that will have features that the original express would never have?

Please explain more deeply what exactly are you asking and what response you expect

b1ek avatar Jul 18 '23 02:07 b1ek

maybe a more updated / better version of this example https://github.com/53js/express-server-app/tree/master

I would recommend you to have a look into the source code.

Under root/lib/application.js you can see that the express() function was called by express and they added some more methods to it.

Here is the code in the above mentioned file:

function application() {
	const app = express();

	Object.assign(app, {
		start: (port) => application.start(app, port),
		trustProxy: (value) => application.trustProxy(app, value),
		useApiFinalMiddlewares: (options) => app.use(getApiFinalMiddlewares(options)),
		useHealthyRoute: () => app.get('/healthy', healthy),
		useInitialMiddlewares: (options) => app.use(getInitialMiddlewares(options)),
		useRootRoute: () => app.get('/', root),
	});

	return app;
}

ayhanks avatar Aug 04 '23 18:08 ayhanks