Nodejs Stater Kit for beginers.
This project is maintained by thuyiya
Nodejs Stater Kit is a starter kit for beginers.
You can also:
The overriding design goal for project formatting syntax is to make it as readable, can work with ruler
Softwares and Recommended Node.js Libraries:
This kit requires Node.js v6+ to run.
First of all clone this reposteries.
$ git clone
$ cd nodejs-stater-kit
$ npm install
configer .env…
$ npm i -g nodemon
$ mv .env.default .env
$ code .
Stater kit is currently extended with the following plugins. Instructions on how to use them in your own application are linked below.
Plugin | README |
---|---|
Express | Node.js web framework |
Github | github GitHub API library |
body-parser | Express 4 middleware |
express-session | Express 4 middleware |
mongoose | MongoDB ODM. |
dotenv | Loads environment variables from .env file. |
mocha | Test framework. |
chai | BDD/TDD assertion library |
async | Utility library that provides asynchronous control flow. |
paypal-rest-sdk | PayPal APIs library. |
nodemailer | Node.js library for sending emails. |
morgan | HTTP request logger middleware for node.js. |
body-parser | Node.js body parsing middleware. |
cookie-parser | Parse Cookie header and populate req.cookies with an object keyed by the cookie names. |
Up and running
Want to contribute? Great! Make a change in your file and instantanously see your updates!
Open your favorite Terminal and run these commands.
First Tab:
$ npm run start:dev
(optional) Third:
$ npm run test
.babelrc
on root$ npm i --save-dev babel-cli babel-preset-es2015 babel-preset-stage-2
.eslintrc
in root"eslint.autoFixOnSave": true,
{
"env": {
"es6": true,
"node": true,
"mocha": false
},
"extends": "eslint-config-standard"
}
$ npm i --save-dev eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard
.editorconfig
in root or install editorconfig plugin to VsCode
```
# http://editorconfig.org
root = true[*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true
##### 4. Genarate api docs for public
in terminal
```sh
$ npm install apidoc -g
$ apidoc -i web/routes/api/ -o public/apidoc
launch.json
VsCodelaunch.json
...
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/app.js",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
"cwd": "${workspaceRoot}",
"sourceMaps": true
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
If you got like listen EADDRINUSE :::3000
after you try to re run the serve, you have to kill the pid
$ lsof -i :<PORT>
$ kill -9 <PID>
openssl genrsa -out thuyiya-key.pem 2048
more thuyiya-key.pem
openssl req -new -sha256 -key thuyiya-key.pem -out thuyiya-csr.pem
create certificate base on request openssl x509 -req -in thuyiya-csr.pem -signkey thuyiya-key.pem -out thuyiya-cert.pem
var options = {
key: fs.readFileSync('thuyiya-key.pem'),
cert: fs.readFileSync('thuyiya-cert.pem'),
requestCert: false,
rejectUnauthorized: false
}
https.createServer(options, app).listen(3000, () => {
console.log('listening to 3000 (HTTPS Server)')
})
│
└───config
│ │ index.js
│ │ setups
│ │ │ common.js
│ │ │ facebook.js
│ │ │ index.js
│ │ │ google.js
│ │ │ redis.js
│ │ │ server.js
│
└───models
│ │ user
│ │ │ profile.js
│ │ │ contact.js
│ │ index.js
│
└───test
│ │ api.test.js
│
└───web
│ │ index.js
│ │
│ └───routes
│ │ api
└─── index.js
│ │ index.js
│ │
│ middleware
│ │ index.js
│ │
│
│ .babelrc
│ .eslintrc
│ .editorconfig
│ App.js
│ package.json
│ README.md