Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync master and develop #84

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Bug Report
description: Report a bug in the application
labels: bug
body:
- type: markdown
attributes:
value: |
**Describe the bug**
A clear and concise description of what the bug is.
- type: input
attributes:
label: What is the expected behavior?
description: Describe what you expected to happen.
placeholder: Expected behavior...
- type: input
attributes:
label: What are the steps to reproduce?
description: List the steps to reproduce the issue.
placeholder: Steps to reproduce...
- type: input
attributes:
label: What did you see instead?
description: Describe what you observed instead of the expected behavior.
placeholder: Observed behavior...
- type: input
attributes:
label: Additional context
description: Add any other context about the problem here.
placeholder: Additional context...
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
target-branch: "develop"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
day: "sunday"
labels:
- "npm dependencies"
142 changes: 142 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/node_modules
.env

# Editor dependent folder
.idea
.vscode

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

#coverage folder
coverage/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
Footer

File renamed without changes.
140 changes: 72 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,85 @@
# Nodstarter
## Nodstarter

<p align="center">
<img src="https://github.com/ahmadmoaw/nodstarter-replica/blob/master/asset/logo_1.png" alt="nodstarter" width="150" height="150"/>
<img src="https://github.com/0xh3xa/nodstarter/blob/master/asset/logo_1.png" alt="nodstarter" width="150" height="150"/>
</p>
<br/>

<div align="center">

[![Build Status][build-img]][nodestarter-url]
[![Dependency Status][depend-img]][nodestarter-url]
[![Linux][linux-img]][nodestarter-url]
[![Mac][macos-img]][nodestarter-url]
[![Known Vulnerabilities](https://snyk.io/test/github/dwyl/hapi-auth-jwt2/badge.svg?targetFile=package.json)](https://snyk.io/test/github/dwyl/hapi-auth-jwt2?targetFile=package.json)
[![License][license-img]][nodestarter-url]

<div>
<p>
Nodstarter is a starter application for Node.js designed to facilitate rapid RESTful API development. It provides pre-configured, secured routers, services, and models to streamline the creation of secure and scalable applications.
</p>
</div>

starter application for Node.js to provide rapid Restful APIs development, pre-configured, secured routers, services, and models.

## Table of contents

* [General info](#general-info)
* [Technologies](#technologies)
* [Initial Example](#initial-example)
* [Project structure](#project-structure)
* [Code example](#code-example)
* [Sign in API call example](#sign-in-api-call-example)
* [Environment variables](#environment-variables)
* [Setup](#setup)
* [Before running](#before-running)
* [Demo](#demo)
* [New Ideas](#new-ideas)
* [Future plans](#future-plans)
* [Contributing](#contributing)
* [License summary](#license-summary)
* [NPM statistics](#npm-statistics)
* [Project based](#project-based)

## General info

Nodstarter is a starter application for Node.js to provide rapid Restful APIs development, pre-configured, secured routers, services, and models using different libraries.
<div align="center">
<a href="https://www.npmjs.com/package/nodstarter">
<img src="https://img.shields.io/static/v1?label=build&message=passing&color=light-green&style=flat" alt="Build Status" />
</a>
<a href="https://www.npmjs.com/package/nodstarter">
<img src="https://img.shields.io/static/v1?label=dependencies&message=passing&color=light-green&style=flat" alt="Dependency Status" />
</a>
<a href="https://www.npmjs.com/package/nodstarter">
<img src="https://img.shields.io/static/v1?label=linux&message=passing&color=green&style=flat" alt="Linux" />
</a>
<a href="https://www.npmjs.com/package/nodstarter">
<img src="https://img.shields.io/static/v1?label=macos&message=passing&color=green&style=flat" alt="Mac" />
</a>
<a href="https://snyk.io/test/github/dwyl/hapi-auth-jwt2?targetFile=package.json">
<img src="https://snyk.io/test/github/dwyl/hapi-auth-jwt2/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" />
</a>
<a href="https://www.npmjs.com/package/nodstarter">
<img src="https://img.shields.io/github/license/0xh3xa/nodstarter" alt="License" />
</a>
</div>

This project aims to help writing the secure rest APIs quickly and provide a skeleton to the node.js project to minimize the configuration and avoid starting from scratch.
## Table of Contents

- [General Info](#general-info)
- [Technologies](#technologies)
- [Initial Code](#initial-code)
- [Project Structure](#project-structure)
- [Code Example](#code-example)
- [Sign In API Call Example](#sign-in-api-call-example)
- [Environment Variables](#environment-variables)
- [Setup](#setup)
- [Before Running](#before-running)
- [Demo](#demo)
- [New Ideas](#new-ideas)
- [Future Plans](#future-plans)
- [Contributing](#contributing)
- [License Summary](#license-summary)
- [NPM Statistics](#npm-statistics)
- [Project Based](#project-based)

## General Info

Nodstarter provides a framework for developing secure RESTful APIs quickly. It includes pre-configured routers, services, and models, allowing developers to focus on writing business logic rather than setup and configuration.

## Technologies

01. Node.js
02. Express framework
03. MongoDB
04. Mongoose ORM
05. Lodash
06. Morgan middleware
07. Body-parser middleware
08. Method-override
09. Bcrypt
10. Express-jwt
11. Jsonwebtoken
12. Cors middleware
13. Nodemon
14. Testing libraries: Supertest, Chai and Mocha

## Initial code

Nodstarter contains 3 models with the relationship to `users`, `posts` and `categories`, each of them contains `router`, `controller`, and `model`

- Router: Already defined routers you can change to what you want
- Controller: CRUD operation for the models
- Model: Mongo representation for three models with the relationship:
- **Node.js**: JavaScript runtime for building scalable network applications.
- **Express**: Web framework for Node.js.
- **MongoDB**: NoSQL database for storing data.
- **Mongoose**: ORM for MongoDB.
- **Lodash**: Utility library for JavaScript.
- **Morgan**: HTTP request logger middleware.
- **Body-parser**: Middleware for parsing request bodies.
- **Method-override**: Middleware to allow HTTP verbs such as PUT or DELETE.
- **Bcrypt**: Library for hashing passwords.
- **Express-jwt**: Middleware for JWT authentication.
- **Jsonwebtoken**: Library for signing and verifying JSON Web Tokens.
- **Cors**: Middleware for enabling Cross-Origin Resource Sharing.
- **Nodemon**: Utility for auto-reloading the server during development.
- **Testing Libraries**: Supertest, Chai, and Mocha for testing.

* User to Posts one-to-many
* Posts to Categories many-to-many
## Initial Code

So this is the basis for a node.js project you can start with any of them and change the router to your routes, and use the controller.
Nodstarter includes models for `users`, `posts`, and `categories`, with predefined relationships:

For the model also you can update them and the relationship is already this you can copy-and-paste.
- **User to Posts**: One-to-many.
- **Posts to Categories**: Many-to-many.

In future plans ability to use a command line to create a router, controller, model like Ruby-on-Rails.
These components are organized into routers, controllers, and models to provide a clear structure for API development.

## Project structure

Expand Down Expand Up @@ -117,7 +121,7 @@ In future plans ability to use a command line to create a router, controller, mo
└── logger.js
```

## AUTH Code snippet
## Code example

This is the configuration to the JWT token to the user

Expand Down Expand Up @@ -289,17 +293,17 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md)

## License summary

See <a href="https://github.com/ahmadmoaw/nodstarter-replica/blob/master/.github/LICENSE"/>MIT License</a>
See <a href="https://github.com/0xh3xa/nodstarter/blob/develop/LICENSE"/>License</a>

## NPM statistics

[![NPM](https://nodei.co/npm/nodstarter.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/nodstarter/)

## Project based

<a href="https://github.com/ahmadmoaw/nodstarter"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2Fd%2Fd9%2FNode.js_logo.svg%2F1920px-Node.js_logo.svg.png&f=1&nofb=1" alt="nodejs" width="200" height="110"/></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/ahmadmoaw/nodstarter"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcamo.githubusercontent.com%2Ffc61dcbdb7a6e49d3adecc12194b24ab20dfa25b%2F68747470733a2f2f692e636c6f756475702e636f6d2f7a6659366c4c376546612d3330303078333030302e706e67&f=1&nofb=1" alt="nodejs" width="250" height="110"/></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/ahmadmoaw/nodstarter"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/MongoDB_Logo.svg/768px-MongoDB_Logo.svg.png?20190626143224" alt="nodejs" width="250" height="110"/></a>
<a href="https://github.com/0xh3xa/nodstarter"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2Fd%2Fd9%2FNode.js_logo.svg%2F1920px-Node.js_logo.svg.png&f=1&nofb=1" alt="nodejs" width="200" height="110"/></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/0xh3xa/nodstarter"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcamo.githubusercontent.com%2Ffc61dcbdb7a6e49d3adecc12194b24ab20dfa25b%2F68747470733a2f2f692e636c6f756475702e636f6d2f7a6659366c4c376546612d3330303078333030302e706e67&f=1&nofb=1" alt="nodejs" width="250" height="110"/></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/0xh3xa/nodstarter"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/MongoDB_Logo.svg/768px-MongoDB_Logo.svg.png?20190626143224" alt="nodejs" width="250" height="110"/></a>

[demo-url]: https://github.com/ahmadmoaw/nodstarter/raw/master/asset/demo.gif
[demo-url]: https://github.com/0xh3xa/nodstarter/raw/master/asset/demo.gif
[build-img]: https://img.shields.io/static/v1?label=build&message=passing&color=light-green&style=flat
[depend-img]: https://img.shields.io/static/v1?label=dependencies&message=passing&color=light-green&style=flat
[nodestarter-url]: https://www.npmjs.com/package/nodstarter
Expand All @@ -313,5 +317,5 @@ See <a href="https://github.com/ahmadmoaw/nodstarter-replica/blob/master/.github
[linux-img]: https://img.shields.io/static/v1?label=linux&message=passing&color=green&style=flat
[macos-img]: https://img.shields.io/static/v1?label=macos&message=passing&color=green&style=flat
[linux-url]: [nodestarter-url]
[license-img]: https://img.shields.io/github/license/ahmadmoaw/nodstarter
[license-img]: https://img.shields.io/github/license/0xh3xa/nodstarter
[license-url]: [nodestarter-url]
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var app = require('./server');
var config = require('./server/config');
var logger = require('./server/util/logger');
let app = require('./server');
let config = require('./server/config');
let logger = require('./server/util/logger');

app.listen(config.port);

Expand Down
Loading
Loading