Sample server proof of concept (POC) that handles basic HTTP request. The source code is written in TypeScript with Express framework.
The POC is hosted on Heroku at https://my-server-snoidetx-poc.herokuapp.com.
- Clone the repository to a local path.
- If
npm
is installed, runnpm install
. Otherwise, installnpm
first by runningnpm install -g npm
. - Run
nps start
. The server will be deployed and available on https://localhost:1202/. - This server also supports
nodemon
,concurrently
andpm2
packages. See their websites for commands to run.
GET
from/
. The server will send aHello world!
as HTML.GET
from/user
with query on username. The server will return a JSON object containing a message. For example,GET BASE/user?username=johndoe
returns{"message":"Hello stranger johndoe"}
.POST
to/create-user
with a JSON string as body. The JSON string needs to contain a parameterusername
. For example,POST BASE/create-user
with{"username": "John Doe", "data": "hello"}
returns{"message": "Hi John Doe, your request is successful."}
.