https://github.com/hurricanemark/node-rest-fullstack
NodeJS REST full stack API
https://github.com/hurricanemark/node-rest-fullstack
Last synced: 7 months ago
JSON representation
NodeJS REST full stack API
- Host: GitHub
- URL: https://github.com/hurricanemark/node-rest-fullstack
- Owner: hurricanemark
- Created: 2019-11-06T18:48:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T12:19:12.000Z (almost 3 years ago)
- Last Synced: 2025-01-27T05:27:16.572Z (8 months ago)
- Language: JavaScript
- Size: 3.2 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Intall nodejs using npm
npm install npm@latest -g
## Initialize a project
mkdir node-rest-shop
cd node-rest-shop
npm init
npm install --save express
## Install nodemon (so we don't have to run node server.js each time we made changes to code)
npm install --save-dev nodemon
then, edit packages.json and add under script:
"script": {
...
"start": "nodemon server.js"
}## Install package morgan to maintain logging
npm install --save morgan
## Install body-parser to look at the content of the request
npm install --save body-parser
## Use MongoQB Atlas (free tier)
hurricanemark@gmail.com / markn123$
markn/markn123$## Let's jump in
1. add file server.js
```
const http = require('http');const app = require('./app');
const port = process.env.PORT || 5009;
const server = http.createServer(app);
server.listen(port)
```
2. add file app.js
```
const express = require('express');
const app = express();app.use(( req, res, next ) => {
res.status(200).json({
message: 'It works!'
});
});module.exports = app;
```## Git
git remote add origin https://github.com/hurricanemark/node-rest-fullstack.git
git push -u origin master