Add http-nodejs starter (#73)

* Add http-nodejs starter

* Fix name in package.json
This commit is contained in:
Aiden Bai
2021-04-11 16:52:34 -07:00
committed by GitHub
parent 50ee57407e
commit e3ad92e558
5 changed files with 36 additions and 0 deletions

1
examples/http-nodejs/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules/

View File

@@ -0,0 +1,15 @@
# HTTP Module Example
This example starts an [HTTP Module](https://nodejs.org/api/http.html) server.
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new?template=https%3A%2F%2Fgithub.com%2Frailwayapp%2Fexamples%2Ftree%2Fmaster%2Fexamples%2Fhttp-nodejs)
## 💁‍♀️ How to use
- Install dependencies `yarn`
- Connect to your Railway project `railway init`
- Start the development server `railway run yarn dev`
## 📝 Notes
The server started simply returns a `Hello World` payload. The server code is located in `server.mjs`.

View File

@@ -0,0 +1,10 @@
{
"name": "http-nodejs",
"version": "1.0.0",
"main": "index.js",
"author": "Aiden Bai",
"license": "MIT",
"scripts": {
"start": "node server.mjs"
}
}

View File

@@ -0,0 +1,6 @@
import { createServer } from 'http';
createServer((req, res) => {
res.write('Hello World!');
res.end();
}).listen(process.env.PORT);

View File

@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1