https://github.com/runthis/nodejs
https://github.com/runthis/nodejs
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/runthis/nodejs
- Owner: runthis
- License: mit
- Created: 2022-11-17T16:02:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-17T16:49:13.000Z (over 3 years ago)
- Last Synced: 2025-02-14T22:35:06.792Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kinsta - Hello World - Node.js
An example of how to set your Node.js application up to enable deployment on Kinsta App Hosting services.
> Kinsta’s Application Hosting is a service to run your web apps and any databases side by side in a hassle-free environment, tailored for developer needs and ease of use. App Hosting is currently in an invite-only beta phase, sign up for a test account at [kinsta.com/application-hosting](https://kinsta.com/application-hosting/).
## Dependency Management
During the deployment process Kinsta will automatically install dependencies defined in your `package.json` file.
## Web Server Setup
### Port
Kinsta automatically sets the `PORT` environment variable. You should **not** define it yourself and you should **not** hard-code it into the application. Use `process.env.PORT` in your code when referring to the server port.
```
app.listen(process.env.PORT, () => {
console.log(`Hello World Application is running on port ${process.env.PORT}`)
})
```
### Start Command
When deploying an application Kinsta will automatically create a web process with `npm start` as the entry point. Make sure to use this command to run your server. If you would like to use another command you will need modify the runtime process in MyKinsta.
```
"scripts": {
"start": "node server.js"
},
```
## Deployment Lifecycle
Whenever a deployment is initiated (through creating an application or re-deploying due to an incoming commit) the `npm build` command is run, followed by the `npm start` command.