https://github.com/bradgarropy/node-only-server
Simple web server and REST API using only Node.
https://github.com/bradgarropy/node-only-server
html javascript node nodejs rest rest-api web-app web-application web-server
Last synced: about 2 months ago
JSON representation
Simple web server and REST API using only Node.
- Host: GitHub
- URL: https://github.com/bradgarropy/node-only-server
- Owner: bradgarropy
- Created: 2017-07-02T02:28:45.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-14T06:26:24.000Z (almost 9 years ago)
- Last Synced: 2025-06-03T01:37:35.812Z (about 1 year ago)
- Topics: html, javascript, node, nodejs, rest, rest-api, web-app, web-application, web-server
- Language: JavaScript
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Web Server & REST API Using Only Node
*Learning about the world of JavaScript can be incredibly daunting.
Learning [NodeJS](https://nodejs.org/) is even worse.*
So I decided to write a basic web server and REST API using only [Node](https://nodejs.org/). No express, no pug, no MongoDB, nothing.
My aim was to understand what [Node](https://nodejs.org/) had to offer on its own, and do my best to create a standard web API using just that. I figured somewhere along the way I'd understand why all of these extra modules are so nice to have.
And indeed I did.
## Lessons Learned
Route parsing is a bitch using only the basic modules.
Next iteration of this project will include [Express](https://expressjs.com/) for it's excellent route parsing and middleware options.
## Project Iterations
1. [node-only-server](https://github.com/bradgarropy/node-only-server)
2. [node-express-server](https://github.com/bradgarropy/node-express-server)
3. [node-express-pug-server](https://github.com/bradgarropy/node-express-pug-server)
4. [node-express-pug-mongo-server](https://github.com/bradgarropy/node-express-pug-mongodb-server)
## Features
This simple web application tracks weight measurements. It implements the following HTTP methods:
* GET
* POST
* PATCH
* DELETE
It also offers one page, the index, which shows the current weight entries.
## Usage
First, clone down the repository. Next, run the following command from inside the directory:
`npm start` or `node server`
In order to access the index page, navigate to `localhost:3000` in your browser.
## REST API
Use your favorite REST client, mine is [Postman](https://www.getpostman.com/), to send requests to the server.
### Retrieve Weight Entries
```
GET /api/weight
```
### Add Weight Entry
```
POST /api/weight
Parameters: { "date": "2017-05-17", "weight": 180 }
```
### Update Weight Entry
```
PATCH /api/weight/:date
Parameters: { "weight": 180 }
```
### Remove Weight Entry
```
DELETE /api/weight/:date
```