Clean, minimalistic boilerplate to start your NodeJs project. It helps you structure your file in a more conventional way.
NodeJS is far too powerful to be limited to just running your website. Whether building a website, communicating with the database or writing a script to automate a file process, you can't go wrong with NodeJS.
- Building a worker scripts.
- Stand-alone scripting and automation tool.
- Fully customizable project.
- Forcing you to write clean-easy-to-read code.
- Clean file structuring.
- Following standard naming conventions so collaborators/team8s can understand easily your code.
- Securing your login and api key details by using environment variable -- dotenv
- NodeJs, git installed in your local environment.
- π .env file -- Yes you need this! πππ
- Clone the repo to your local environment.
- In the command prompt run the following commands:
$ git clone https://github.com/yortrosal/nodejs-boilerplate.git $ cd nodejs-boilerplate
- run
$ npm install
to install initial dependencies. - Make sure you have .env file available.
Or generate one:
$ cp .env.example .env
(edit it with your secret keys and other credentials) - Once you have the .env file setup in the main directory.
- run
βΆοΈ $ npm start
to start the program. It will run the script from the app.js file. - Modify the package.json file. Edit the project name and other stuff.
- Finally, start and build your application scripts. Customize your project however you like.
Try to add your script and other stuff inside /core folder.
If you want to run specific script inside the ./core folder, try to set it in package.json script.
For example, when you try to run ./core/hello-world.js
, instead of cd core && node hello-world
, you can use a command that was set in package.json file npm run hello-world
.
It has variety of usage. Find out more. But the sole purpose of using .env file for our project is to secure our credentials such as logins, api keys, and other important stuff. It is important not to include your .env file in our repository specially when your project is public.
nodejs-boilerplate
βββ core
β βββ custom-subfolder-example
β β βββ example1.js
β β βββ example2.js
β β βββ example3.js
β β
β βββ access-credentials.js
β βββ hello-world.js
β
βββ .env.example
βββ .env // store all your credentials here
βββ .plans
βββ .gitignore
βββ app.js
βββ package.json
βββ README.md
- This is where you put your login credentials, secret keys, and other confidential information. Never include when you commit your repository. Make sure it is included in .gitignore file so it wont be included.
- If things went wrong, google it first. People ahead of you have had similar issues in the past and solved it.
- Last resort. -- Contact Jorge. He'd be happy to help you.
- Jorge Rosal - GitHub
- Feel free to submin PR. Please follow ESLINT Rule.
The MIT License (MIT) Jorge Rosal