Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Hot reload api - #118

Merged
devaquila merged 9 commits into
devfrom
poc-hot-reload-api
Aug 13, 2021
Merged

devaquila merged 9 commits into
devfrom
poc-hot-reload-api

Conversation

@Its-Just-Nans

@Its-Just-Nans Its-Just-Nans commented Jul 16, 2021 •

Copy link
Copy Markdown
Contributor

With this PR, you can now reload easily the entire API (/services and /routes) whitout restarting the server

To do this :

  • be in development mode
  • do a GET on the URL .../api/reloadAPI

If the message is "ok" the API has been restarted

@Its-Just-Nans
Its-Just-Nans requested a review from devaquila July 16, 2021 09:07
@Its-Just-Nans Its-Just-Nans self-assigned this Jul 16, 2021
@Its-Just-Nans

Copy link
Copy Markdown
Contributor Author

Explanation (how it's work) :
We delete router from the express stack
We delete cache of require (to reload files)
We re-add router of the api to the express stack

Comment thread server.js Outdated
require('./services/cache').cacheSetting();
const apiRouter = require('./routes').InitRoutes(express, server);
if (dev) {
const reloadRouter = express.Router();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move with new code to new function

@devaquila devaquila left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move with new code to new function

@Its-Just-Nans

Its-Just-Nans commented Aug 9, 2021 •

Copy link
Copy Markdown
Contributor Author

I think the POC can be better if you accept this PR #124

@devaquila
devaquila merged commit b10aee8 into dev Aug 13, 2021
@devaquila
devaquila deleted the poc-hot-reload-api branch August 13, 2021 10:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants