Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a custom framework of express #5214

Open
RjManhas opened this issue Jun 18, 2023 · 4 comments
Open

Creating a custom framework of express #5214

RjManhas opened this issue Jun 18, 2023 · 4 comments

Comments

@RjManhas
Copy link

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
Copy link
Author

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

@RjManhas
Copy link
Author

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

@b1ek
Copy link

b1ek commented Jul 18, 2023

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

@ayhanks
Copy link

ayhanks commented Aug 4, 2023

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants